note 17525 deleted from function.array-search by jimw

From: Date: Thu, 20 Dec 2001 23:46:28 +0000
Subject: note 17525 deleted from function.array-search by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-23593@lists.php.net to get a copy of this message
I have found that this function does not perform as intended, all the time. I had an array that I was searching, and the results of the search was 0. However, the value I was searchign for was not in the array. The function should return FALSE in this instance. Here is the code (for what it is worth:) $allAccounts = getAccountsByProducerCode($session["producer_code"]); $myAccounts = array(); for ( $x=0; $x<count($allAccounts); $x++ ) { array_push($myAccounts,$allAccounts["$x"]->account_number); } if ( in_array($account_number,$myAccounts) === FALSE ) { $errorMsg = "Sorry, but your user does not have access to this account."; include("dsp_ErrorPage.php"); exit; } else { .... }

« previous php.notes (#23593) next »