Regular Expression with Preg_match
Posted: Wed Apr 18, 2007 10:28 pm
Code: Select all
$pcode = 'LVG813';
$result[0] = 'uploads/LVG813x.jpg';
$result[1] = 'uploads/LVG813-1.jpg';
$result[2] = 'uploads/LVG813-2.jpg';
$result[3] = 'uploads/LVG813-3.jpg';
$result[4] = 'uploads/LVG813-4.jpg';
for($z = 0; $z <= sizeof($results); $z++){
if(preg_match('/(.*?)' . preg_quote($pcode, '/').'(.*?)\\.(.*?)/i',$results[$z])){
echo $results[$z];
}
}The current regular expression only pulls out the file name in first array.