note 107197 deleted from function.array-search by tularis

From: Date: Sat, 14 Jan 2012 11:51:07 +0000
Subject: note 107197 deleted from function.array-search by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-185647@lists.php.net to get a copy of this message
Note Submitter: Carlos Martin Reason: bad code ---- 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; }

« previous php.notes (#185647) next »