|
Posted by Gilles Ganault on 06/12/07 18:37
Hello
I need to extract some bits of information from a web page, so
I used preg_match_all. I was wondering if there's a simpler algorithm,
or if that's the way it's done:
===========
preg_match_all("|$regex|smi",$buffer,$matches,PREG_PATTERN_ORDER);
$elements=sizeof($matches);
$x=sizeof($matches,TRUE);
$rows = $x/$elements;
$rows--; //Why is the last row empty?
print "elements=$elements, x=$x, $rows<br>";
for ($row=0;$row < $rows;$row++){
$string = "";
for($element=1;$element < $elements;$element++){
$string .= $matches[$element][$row] . ",";
}
//Remove trailing ","
$string = trim($string, ",");
print "$string<hr>";
}
===========
Thank you.
Navigation:
[Reply to this message]
|