An example analysis of PHP array index and key-value manipulation techniques
This article describes the PHP array index and key-value manipulation techniques. Share to everyone for your reference. Specific as follows:
?
1 2 3 4 5 |
$array = Array ("A", "B", "C"); Defining arrays $array [] = "Simon"; Add a new array element Print_r ($array); Output array ?> |
?
1 2 3 4 5 |
$array = Array ("A", "B", "C"); Defining arrays $array [9] = "Simon"; Add a new array element Print_r ($array); Output array ?> |
?
1 2 3 4 5 6 7 8 9 Ten One + All + + 2 0 [ ] |
!--? php //Create a simple array $ar Ray = Array (0=>1, 1=>2, 2=>3, 3=>4, 6=>5); Print_r ($array); //Now update the value in the array with the key 2 to + $array [2] =; Print_r ($array); //Add a key now $array ["X"] =; Print_r ($array); //Delete all keys now, but keep the structure of the array itself foreach ($array as $i = = $value) { unset ($array [$i]); } Print_r ($array); //Add a key again $array [] =; Print_r ($array); //re-index using the Array_values function $array = array_values ($array); $array [] =; Print_r ($array); ? |
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/1020888.html www.bkjia.com true http://www.bkjia.com/PHPjc/1020888.html techarticle An example of PHP array index and key-value manipulation techniques This article describes the PHP array index and key-value manipulation techniques. Share to everyone for your reference. Specific as follows:? 1 2 3 4 5? PHP $arra ...