On 2012-09-01 21:23, Sherif Ramadan wrote:

$array[0] = 'first element';
$array[99999] = 'second element';
var_dump($array);
/*
array(2) {
   [99999]=>
   string(14) "second element"
   [0]=>
   string(13) "first element"
}
*/

Just correcting this as it was a copy/paste fail... The above code
would produce:

array(2) {
   [0]=>
   string(13) "first element"
   [99999]=>
   string(14) "second element"
}


Or:

<?php
$array = [];
$array[1] = 42;
$array[0] = 17;
$array[2] = 99;
print_r($array);
?>
And, just to be explicit, following that up with:
<?php
reset($array);
echo key($array),"\t",current($array),"\n";
next($array);
echo key($array),"\t",current($array),"\n";
next($array);
echo key($array),"\t",current($array),"\n";
?>

===>

Array
(
    [1] => 42
    [0] => 17
    [2] => 99
)
1       42
0       17
2       99


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to