|
Posted by Andy Hassall on 10/21/06 21:31
On 21 Oct 2006 11:40:15 -0700, "Daz" <cutenfuzzy@gmail.com> wrote:
>Hi Everyone. I know this is a stupid question, but I have been sifting
>through php.net and I am about ready to pull my hair out over it...
>
>I have seen a function similar to in_array() and array_search() which
>returns the 0-based index number of the specified element if it exists.
Isn't that what array_search already does on numerically-indexed arrays?
Or do you want the index of the key for the element, in the array of keys for
the array? In which case it sounds like two array_search() calls:
<?php
$a = array(
'fish' => 'fingers',
'dog' => 'hot dog',
'cow' => 'steak',
);
print array_search(array_search('hot dog', $a), array_keys($a));
?>
Output: 1
--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
[Back to original message]
|