In the PHP array assignment is very simple, if it is a one-dimensional array assignment than a two-dimensional array or multidimensional array is simpler, below I will give you to the array assignment of various examples introduced, there is a need to understand the friend can refer to.
What about the PHP array assignment? As follows:
Example 1, one-dimensional array assignment
The code is as follows |
Copy Code |
$My _array=array (); $My _array[]= "www" $My _array[]= "helpphp"; $My _array[]= "cn"; |
Destroying an array
The code is as follows |
Copy Code |
Unset ($My _array[0]; unset ($My _array); |
Example 2, two-dimensional array assignment
The code is as follows |
Copy Code |
$data _array=array ($total, 2);//The number of records $datarows for the query $data _array[$i][2]= $Area;//Hint error: Cannot use a scalar value as an array |
The specific cycle is as follows
The code is as follows |
Copy Code |
$i = 0; while ($result = $db->fetch_array ($query)) {$Area = $result ["area"]; $data _array[$i][2]= $Area; Error! $i = $i +1; } |
http://www.bkjia.com/PHPjc/628683.html www.bkjia.com true http://www.bkjia.com/PHPjc/628683.html techarticle in PHP array assignment is very simple, if it is a one-dimensional array assignment than a two-dimensional array or multidimensional array is more simple, let me give you students to the array assignment of various examples introduced, there is a need ...