05-03-2009, 03:12 AM
|
#1 (permalink)
|
|
The Gregarious
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
|
searching array
Hey guys/gals,
I am trying to output only the items in the array that have ISBN in it. I tried both array_search() and in_array() functions and each time I got errors for using invalid data types in the second field.
Code:
<?php
$test = array('Wfjheighe','ISBN:454656','ISBN:9090943');
foreach ($test as $id) {
if(array_search('ISBN',$id)) echo $id . "<BR />";
}
?>
AND
<?php
$test = array('Wfjheighe','ISBN:454656','ISBN:9090943');
foreach ($test as $id) {
if(in_array('ISBN',$id)) echo $id . "<BR />";
}
?>
I basically just want ISBN:454656 and ISBN:9090943 to be outputted...
What am I doing wrong?
|
|
|
|