Re: array question
| From: | Ernest E Vogelsinger | Date: | Mon, 10 Mar 2003 15:42:53 +0000 |
| Subject: | Re: array question | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-138964@lists.php.net to get a copy of this message | ||
At 16:35 10.03.2003, Jason Wong said:
--------------------[snip]--------------------
>Not very elegant -- there must be a better way?
>
>foreach ($doo as $key => $value) {
> print "Key:$key Value:$value";
> break;
>}
--------------------[snip]--------------------
Possibly using array_keys()?
$keys = array_keys($doo);
echo "First key is \"{$keys[0]}\"";
array_keys() comes in handy if you want to have random access to an
associtive array without knowing the keys.
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/