Last active
December 18, 2015 08:09
-
-
Save shyamsalimkumar/5752358 to your computer and use it in GitHub Desktop.
PHP - Automatically creates variables with the same name as the key in the POST array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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