note 72139 added to function.array-search
| From: | erickdotxavieratgmaildotcom at osu1 dot php dot net | Date: | Thu, 04 Jan 2007 12:57:28 +0000 |
| Subject: | note 72139 added to function.array-search | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-121277@lists.php.net to get a copy of this message | ||
Modifing the "multiarray_search" to unordered Array....
<?PHP
function multiarray_search($arrayVet, $campo, $valor){
while(isset($arrayVet[key($arrayVet)])){
if($arrayVet[key($arrayVet)][$campo] == $valor){
return key($arrayVet);
}
next($arrayVet);
}
return -1;
}
//I.e.:
$myArr = array(
13 => array(
"fruit" => "banana"
),
654 => array(
"fruit" => "apple"
),
2445 => array(
"fruit" => "nothing more"
)
);
print(multiarray_search($myArr , "fruit", "apple"));
/*
Output:
654
*/
//and
print(multiarray_search($myArr , "fruit", "orange"));
/*
Output:
-1
*/
?>
----
Server IP: 200.185.126.100
Probable Submitter: 201.37.12.130
----
Manual Page -- http://www.php.net/manual/en/function.array-search.php
Edit -- https://master.php.net/note/edit/72139
Del: integrated -- https://master.php.net/note/delete/72139/integrated
Del: useless -- https://master.php.net/note/delete/72139/useless
Del: bad code -- https://master.php.net/note/delete/72139/bad+code
Del: spam -- https://master.php.net/note/delete/72139/spam
Del: non-english -- https://master.php.net/note/delete/72139/non-english
Del: in docs -- https://master.php.net/note/delete/72139/in+docs
Del: other reasons-- https://master.php.net/note/delete/72139
Reject -- https://master.php.net/note/reject/72139
Search -- https://master.php.net/manage/user-notes.php