note 17525 added to function.array-search
| From: | sirwallyc at netscape dot net | Date: | Wed, 12 Dec 2001 21:21:27 +0000 |
| Subject: | note 17525 added to function.array-search | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-22558@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 { .... }
--
http://www.php.net/manual/en/function.array-search.php
http://master.php.net/manage/user-notes.php?action=edit+17525
http://master.php.net/manage/user-notes.php?action=delete+17525
http://master.php.net/manage/user-notes.php?action=reject+17525