Thread: searching array
View Single Post
Old 05-03-2009, 05:01 AM   #3 (permalink)
Kalle
The Frequenter
Zend Certified 
 
Join Date: Sep 2007
Location: Denmark
Posts: 352
Thanks: 8
Kalle is on a distinguished road
Default

You are using in_array incorrectly in the second sample code; You are iterating over a block of elements and pass the second parameter to in_array() as a string where it would expect an array, further though the first parameter for in_array() does not work as a wildcard, it will see if theres an element with that content in this case ISBN and nothing else, meaning it will always return false here.

What you need to do is to use something like str[i]str():
PHP Code:
...
if(
stristr($id'ISBN') !== false)
{
    ...
}
... 
__________________
Send a message via MSN to Kalle Send a message via Skype™ to Kalle
Kalle is offline  
Reply With Quote