Array keys expected behaviour?
| From: | Arjen Brouwer | Date: | Tue, 20 May 2003 08:40:15 +0000 |
| Subject: | Array keys expected behaviour? | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-1772@lists.php.net to get a copy of this message | ||
Hi,
Take the following code:
<?
$car = array(
"brand" => "Porsche"
,"color" => black
);
function nvl(&$var, $default = false) {
return (isset($var)) ? $var : $default;
}
echo "Color: " . nvl($car["color"]) . "\n";
echo "Spoiler: " . nvl($car["spoiler"], "yes");
echo "\n\n";
print_r($car);
?>
Output:
---
Color: black
Spoiler: yes
Array
(
[brand] => Porsche
[color] => black
[spoiler] =>
)
---Look at the output of the last print_r, the key "spoiler" is defined? But is never
defined in the code ...Just wondering, is this the expected behaviour?Running PHP4.3.2RC3Cheers,
Arjen