note 107197 added to function.array-search
| From: | CarlosMartin at osu1 dot php dot net | Date: | Fri, 13 Jan 2012 23:51:22 +0000 |
| Subject: | note 107197 added to function.array-search | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-185641@lists.php.net to get a copy of this message | ||
I was looking for a function to help to determine if a key value was present in a multidimensional
array and after a couple of hours of fail searchers I decided to create one myself and I want to
share it with anybody who needs it
//Multidimensional Array created dynamically
array_push($table1, array('PART_NUM'=>$PART_NUM, 'COST'=> $COST,
'DISC_MSRP'=>$DISC_MSRP,
'DISC_DEALER'=>$DISC_DEALER,
'DISC_1X'=>$DISC_1X, 'DISC_2X'=>$DISC_2X,
'DISC_3X'=>$DISC_3X,
'CHASSIS'=>$chassis_cost,
'INPUTS'=>$inputs_cost, 'POWER_PACK'=>$power_pack_cost,
'OS'=>$os_cost, 'OS_DRIVES'=>$os_driveS_cost,
'STORAGE'=>$storage_cost));
//Function to find a key value in a multidimensional Array
private function in_multi_array($needle, $key, $haystack)
{
for($n = 0; $n < count($haystack); $n++){
if($haystack[$n][$key]==$needle){
return true;
}
}
return false;
}
----
Server IP: 69.147.83.197
Probable Submitter: 70.89.173.178
----
Manual Page -- http://www.php.net/manual/en/function.array-search.php
Edit -- https://master.php.net/note/edit/107197
Del: integrated -- https://master.php.net/note/delete/107197/integrated
Del: useless -- https://master.php.net/note/delete/107197/useless
Del: bad code -- https://master.php.net/note/delete/107197/bad+code
Del: spam -- https://master.php.net/note/delete/107197/spam
Del: non-english -- https://master.php.net/note/delete/107197/non-english
Del: in docs -- https://master.php.net/note/delete/107197/in+docs
Del: other reasons-- https://master.php.net/note/delete/107197
Reject -- https://master.php.net/note/reject/107197
Search -- https://master.php.net/manage/user-notes.php