- var_dump: documentation ( source)
- reset: documentation ( source)
- end: documentation ( source)
- key: documentation ( source)
<?php
$array = array();
echo PHP_EOL . ' on empty array: ' . PHP_EOL;
var_dump(key($array));
$array[] = 'f';
echo PHP_EOL . ' size one array: ' . PHP_EOL;
var_dump(key($array));
$array[] = 'f';
echo PHP_EOL . ' size two array: ' . PHP_EOL;
var_dump(key($array));
echo PHP_EOL . ' within loop: ' . PHP_EOL;
foreach ($array as $key => $value) {
var_dump(key($array));
if ($key == 0) {
echo PHP_EOL . ' unsetting first element.... ' . PHP_EOL;
unset($array[$key]);
}
if ($key == 1) {
echo PHP_EOL . ' unsetting second element.... ' . PHP_EOL;
unset($array[$key]);
}
}
echo PHP_EOL . ' after loop: ' . PHP_EOL;
var_dump(key($array));
reset($array);
echo PHP_EOL . ' after reset: ' . PHP_EOL;
var_dump(key($array));
end($array);
echo PHP_EOL . ' after end: ' . PHP_EOL;
var_dump(key($array));
echo PHP_EOL . ' trying to trigger "Undefined index: " error: with NULL key' . PHP_EOL;
$array[null];
echo PHP_EOL . ' trying to trigger "Undefined index: " error: with empty string key' . PHP_EOL;
$array[''];