This article mainly introduces how php uses the key value of the post array to create and assign values to variables of the same name. It involves php Array Operations and is very useful. For more information, see
This article mainly introduces how php uses the key value of the post array to create and assign values to variables of the same name. It involves php Array Operations and is very useful. For more information, see
This example describes how php creates and assigns values to variables of the same name using the key value of the post array. Share it with you for your reference. The details are as follows:
This code automatically creates a variable of the same name based on the key value of the post array. This function is very convenient to use and does not need to declare variables in advance.
<? Php $ expected = array ('username', 'age', 'city', 'street'); foreach ($ expected as $ key) {if (! Empty ($ _ POST [$ key]) {$ {key }== _ POST [$ key] ;}else {$ {key }= NULL ;}}?>
I hope this article will help you with php programming.