Example #6 Keys not on all elements
<?php
$array = array(
"a",
"b",
6 => "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