RE: Searching for array keys
| From: | Tim Ward | Date: | Fri, 04 May 2001 08:38:43 +0000 |
| Subject: | RE: Searching for array keys | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-51386@lists.php.net to get a copy of this message | ||
if (isset($array["key"]))
Tim Ward
Senior Systems Engineer
Please refer to the following disclaimer in respect of this message:
http://www.stivesdirect.com/e-mail-disclaimer.html
> -----Original Message-----
> From: Martin Skjöldebrand [mailto:chimbis@skjoldebrand.org]
> Sent: 04 May 2001 06:13
> To: php-general@lists.php.net
> Subject: Searching for array keys
>
>
> What's the best way of finding out if a specific array key is
> in an array?
> I have an associative array which *may* look like
> (car =>saab, house => mansion, countyW=> A) but can equally
> well look like
> (boat => daycruiser, house => flat, county => B).
>
> I want to find out if the key "car" is in the array and do
> something if it
> is.
>
> I found:
>
> $os = array ("Mac", "NT", "Irix", "Linux");
> if (in_array ("Irix", $os)){
> <do stuff>;
> }
>
> But that only works on the values. But it is exactly what I
> want to do on
> keys instead.
>
> Suggestions?
>