Thread: searching array
View Single Post
Old 05-03-2009, 03:32 AM   #2 (permalink)
Enfernikus
The Addict
 
Enfernikus's Avatar
 
Join Date: Jun 2008
Posts: 335
Thanks: 2
Enfernikus is on a distinguished road
Default

PHP Code:
<?php

$test 
= array('Wfjheighe','ISBN:454656','ISBN:9090943');
$term '/ISBN:(.*?)/Us';

foreach( 
$test as $id )
{
    if( 
preg_match($term$id$match) )
    {
        echo 
$match[0], '<br />';
    }
}

?>
This'll output what you want, how ever for future references some pointers.

when using echo to output data please the comma instead of the period to concatenate strings it is faster.

when you're processing strings without variables in them use single quotes as PHP doesn't process them.

Unless I'm mistaken standards mandate html be lowercase so <BR /> should <br />

P.S - I am not sure this would be the best method.
Enfernikus is offline  
Reply With Quote