Saturday, 28 July 2012

php Example #6 Keys not on all elements

Example #6 Keys not on all elements
<?php
$array 
= array(
         
"a",
         
"b",
    
=> "c",
         
"d",
);
var_dump($array);?>
The above example will output:
array(4) {
  [0]=>
  string(1) "a"
  [1]=>
  string(1) "b"
  [6]=>
  string(1) "c"
  [7]=>
  string(1) "d"
}
As you can see the last value "d" was assigned the key 7. This is because the largest integer key before that was 6.

No comments:

Post a Comment