[preg_match_all] Better algorithm?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

    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:


$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.

Re: [preg_match_all] Better algorithm?

On 12.06.2007 20:37 Gilles Ganault wrote:
Quoted text here. Click to load it

Try using foreach to iterate through your arrays.

gosha bine

extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok

Re: [preg_match_all] Better algorithm?

Quoted text here. Click to load it

I'll try it. Thanks.

Site Timeline