array_search returns the key-value of the searched value that is found... in the first case... the returned key is 0.... because it's the first element... however... 0 is also the same as FALSE...
you should use === (three ='s) ... it's used to compare both value and type... (and 0 is not the same type as FALSE)... Greets, Edward ----- Original Message ----- From: "Roger Keays" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, February 26, 2002 10:29 AM Subject: [PHP] array_search > Hi, > > Can anybody explain why the output of this script is > > not found > Found! > > Here is the script... > > $legalfields = array("reasonForRepair"); > if (array_search("reasonForRepair", $legalfields) == TRUE) { > echo "Found!<br>"; > } else { > echo "not found<br>"; > } > $legalfields = array("foo", "reasonForRepair"); > if (array_search("reasonForRepair", $legalfields) == TRUE) { > echo "Found!"; > } else { > echo "not found"; > } > ?> > > Thanks in advance, > > Roger > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php