Re: [PHP] search array for value
How do I search an array? For example if I want to know if $array contains 1... Regards, Matthew Delmarter This is bad, use in_array() or array_search(). in_array() returns TRUE if element is found in array. array_search returns the key of matching element, FALSE otherwise. Lenar for ($i = 0; $i count($array); $i++) { if ($array[$i] == 1) { //do something exit; } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] search array for value
In a message dated 7/31/01 12:32:59 AM Eastern Daylight Time, [EMAIL PROTECTED] writes: How do I search an array? For example if I want to know if $array contains 1... Regards, Matthew Delmarter for ($i = 0; $i count($array); $i++) { if ($array[$i] == 1) { //do something exit; } }
RE: [PHP] search array for value
How about; $valuelist = explode(, , $array); $query = select * from table where column in ($valuelist); etc. Warren Vail -Original Message- From: Matthew Delmarter [mailto:[EMAIL PROTECTED]] Sent: Monday, July 30, 2001 9:41 PM To: PHP Mailing List Subject:[PHP] search array for value How do I search an array? For example if I want to know if $array contains 1... Regards, Matthew Delmarter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] search array for value
Sorry, mixed this up with your other query; For this If(in_array(1, $array)) { } Warren Vail -Original Message- From: Warren Vail [mailto:[EMAIL PROTECTED]] Sent: Monday, July 30, 2001 9:57 PM To: Matthew Delmarter; PHP Mailing List Subject:RE: [PHP] search array for value How about; $valuelist = explode(, , $array); $query = select * from table where column in ($valuelist); etc. Warren Vail -Original Message- From: Matthew Delmarter [mailto:[EMAIL PROTECTED]] Sent: Monday, July 30, 2001 9:41 PM To: PHP Mailing List Subject:[PHP] search array for value How do I search an array? For example if I want to know if $array contains 1... Regards, Matthew Delmarter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]