note 90711 added to function.array-search
| From: | n-regen at osu1 dot php dot net | Date: | Tue, 05 May 2009 17:36:48 +0000 |
| Subject: | note 90711 added to function.array-search | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-154256@lists.php.net to get a copy of this message | ||
If you only know a part of a value in an array and want to know the complete value, you can use the
following function:
<?php
function array_find($needle, $haystack)
{
foreach ($haystack as $item)
{
if (strpos($item, $needle) !== FALSE)
{
return $item;
break;
}
}
}
?>
The function returns the complete first value of $haystack that contains $needle.
----
Server IP: 69.147.83.197
Probable Submitter: 79.240.88.131
----
Manual Page -- http://www.php.net/manual/en/function.array-search.php
Edit -- https://master.php.net/note/edit/90711
Del: integrated -- https://master.php.net/note/delete/90711/integrated
Del: useless -- https://master.php.net/note/delete/90711/useless
Del: bad code -- https://master.php.net/note/delete/90711/bad+code
Del: spam -- https://master.php.net/note/delete/90711/spam
Del: non-english -- https://master.php.net/note/delete/90711/non-english
Del: in docs -- https://master.php.net/note/delete/90711/in+docs
Del: other reasons-- https://master.php.net/note/delete/90711
Reject -- https://master.php.net/note/reject/90711
Search -- https://master.php.net/manage/user-notes.php