note 50603 deleted from function.array-search by betz

From: Date: Wed, 20 Apr 2005 19:41:11 +0000
Subject: note 50603 deleted from function.array-search by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-88287@lists.php.net to get a copy of this message
Note Submitter: info at starbum dot com ---- This drove me mad for hours. Remember that the result of array_search might return the first position in the array, which would be "0". However, I was testing for a false value by doing this: if(!$key){ return false; }else{ return true; } when you should be doing this: if($key !== false){ return $key; }else{ return false; } Also, remember that you can search multi-dimentional arrays by specifying: $key = array_search($your_val,$your_arr[0]); or use and associative array by: $key = array_search($your_val,$your_arr['array_name']); Hope this saves you all some headaches :0)

« previous php.notes (#88287) next »