You are here: Re: Can't find built-in PHP function which I know exists... « PHP Programming Language « IT news, forums, messages
Re: Can't find built-in PHP function which I know exists...

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация