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_O RDER);
$elements=sizeo f($matches);
$x=sizeof($matc hes,TRUE);
$rows = $x/$elements;
$rows--; //Why is the last row empty?
print "elements=$elem ents, x=$x, $rows<br>";
for ($row=0;$row < $rows;$row++){
$string = "";
for($element=1; $element < $elements;$elem ent++){
$string .= $matches[$element][$row] . ",";
}
//Remove trailing ","
$string = trim($string, ",");
print "$string<hr >";
}
===========
Thank you.
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_O RDER);
$elements=sizeo f($matches);
$x=sizeof($matc hes,TRUE);
$rows = $x/$elements;
$rows--; //Why is the last row empty?
print "elements=$elem ents, x=$x, $rows<br>";
for ($row=0;$row < $rows;$row++){
$string = "";
for($element=1; $element < $elements;$elem ent++){
$string .= $matches[$element][$row] . ",";
}
//Remove trailing ","
$string = trim($string, ",");
print "$string<hr >";
}
===========
Thank you.
Comment