doni49 Posted November 20, 2006 Share Posted November 20, 2006 PREG_PATTERN_ORDER do? I tried it both on there and NOT on there. In both cases the results looked the same to me.I'm using the following to retrieve the name and default value of all the fields on the page (setting up a screen scraper).[code]preg_match_all('/<INPUT.*?NAME=(.*)[\s]+.*VALUE="(.*)">/imU',$page,$matches, PREG_PATTERN_ORDER);[/code]The following is the array that get's created by that code:[quote]( [0] => Array ( [0] => <input name="action" type="hidden" value="transmit"> [1] => <INPUT NAME=Fld1 TYPE=Text SIZE=2 MAXLENGTH=2 VALUE=""> [2] => <INPUT NAME=Fld2 TYPE=Text SIZE=1 MAXLENGTH=1 VALUE=""> [3] => <input type="submit" style="width:75px" name="transmit" value="Transmit"> [4] => <input type="submit" style="width:75px" name="quit" value="Quit"> [5] => <input type="submit" style="width:75px" name="exit" value="Exit"> ) [1] => Array ( [0] => "action" [1] => Fld1 [2] => Fld2 [3] => "transmit" [4] => "quit" [5] => "exit" ) [2] => Array ( [0] => transmit [1] => [2] => [3] => Transmit [4] => Quit [5] => Exit ))[/quote]It would be SO much simpler for me if $match[0] contained all the matches from the first field and $match[1] had all the matches from the second field etc. This is what I was HOPING "order" would do.Is there someway to have it return the following instead of what it is giving me?[quote]Array( [0] => Array ( [0] => <input name="action" type="hidden" value="transmit"> [1] => <INPUT NAME=Fld1 TYPE=Text SIZE=2 MAXLENGTH=2 VALUE=""> [2] => <INPUT NAME=Fld2 TYPE=Text SIZE=1 MAXLENGTH=1 VALUE=""> [3] => <input type="submit" style="width:75px" name="transmit" value="Transmit"> [4] => <input type="submit" style="width:75px" name="quit" value="Quit"> [5] => <input type="submit" style="width:75px" name="exit" value="Exit"> ) [1] => Array ( [0] => "action" [1] => transmit ) [2] => Array [0] => Fld1 [1] => "" } [3] => Array [0] => Fld2 [1] => "" } [4] => Array [0] => "transmit" [1] => "Transmit" } [5] => Array [0] => quit [1] => "Quit" } [6] => Array [0] => exit [1] => "Exit" })[/quote]Thanks! Quote Link to comment Share on other sites More sharing options...
c4onastick Posted December 8, 2006 Share Posted December 8, 2006 http://us3.php.net/manual/en/function.preg-match-all.phpReally your only two options are:[code]Array ( Array ( Whole Matches ), Array ( First Matches ), Array ( Second Matches ), ...)[/code]or[code]Array ( Array ( Whole First Match, First Match First Capture, First Match Second Capture, ...), Array ( Whole Second Match, Second Match First Capture, Second Match Second Capture, ...), ...)[/code]I've generally found the latter (without the PREG_PATTERN_ORDER flag set) easier to work with. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.