# Array keys expected behaviour?

- Thread: https://externals.io/message/1772
- Original archive: https://news-web.php.net/php.internals/1772
- Started by Arjen Brouwer on 2003-05-20T08:40:15+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #1772 — Arjen Brouwer — 2003-05-20T08:40:15+00:00

URL: https://externals.io/message/1772#1772

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

---

## #1773 — David Grant — 2003-05-20T09:01:32+00:00

URL: https://externals.io/message/1772#1773 · In reply to: #1772

Arjen Brouwer wrote:
> ---Look at the output of the last print_r, the key "spoiler" is defined?

Look at the second note here:

http://www.php.net/manual/en/language.references.whatdo.php

-- 
David Grant
Web Developer

david.grant@wiredmedia.co.uk
http://www.wiredmedia.co.uk

Tel: 0117 930 4365, Fax: 0870 169 7625

Wired Media Ltd
Registered Office: 43 Royal Park, Bristol, BS8 3AN
Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD

Company registration number: 4016744

**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

**********************************************************************
