Skip to content

Instantly share code, notes, and snippets.

@shalaby
Created March 5, 2014 08:45
Show Gist options
  • Save shalaby/9363515 to your computer and use it in GitHub Desktop.
Save shalaby/9363515 to your computer and use it in GitHub Desktop.
Automatically creates variables with the same name as the key in the POST array
$expected=array('username','age','city','street');
foreach($expected as $key){
if(!empty($_POST[$key])){
${key}=$_POST[$key];
}
else{
${key}=NULL;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment