note 10123 deleted from function.array by irc-html
| From: | irc-html@php.net | Date: | Sat, 19 Jan 2002 20:53:35 +0000 |
| Subject: | note 10123 deleted from function.array by irc-html | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-25429@lists.php.net to get a copy of this message | ||
When I first started using PHP I read about xx_fetch_array supporting both named and numeric keys
and I thought that it was a general capability of PHP to reference values in an array with both a
number and/or a name if you specified a name for the key.
ie: in the array:
$array = array("name" => "bob");
I could return "bob" with both:
$array["name"] and $array[0]
I was very wrong and when I printed out the array returned by pg_fetch_array to see why/how their
existed an exception to this:
Array([0]=>Presentation[module_category]
=>Presentation[1]=>textarea[module_name]=>textarea[2] => 1[id] => 1)
It explains how in the case of xx_fetch_array you can use either a numeric or associative key value
- They've added every value twice! Once with a numeric key and once with the named key. This
technique could be useful for your own code.
Furthermore, coming from using Tango and Purity's WebSiphon I kept looking for a means to refer
to a value in relative manner without necessarily knowing key values.
ie: $array[1st item][2nd item];
Initially I thought $array[0][1]; would do this, but ONLY if they used ONLY numeric indexes and only
if you KNOW FOR SURE that the keys start with [0] and increment without ever skipping.
Bottom line: there is no means to directly reference a value in an array relatively.