Page 1 of 1

Not getting all the information out of an array.

Posted: Mon Apr 09, 2007 12:47 am
by afbase
Ok I am trying to REGEX this very large array which kinda goes like this:
[["TW","21st Century Insurance Group","","/about/listed/tw.html"],["MMM","3M Company","","/about/listed/mmm.html"],["KDE","4 Kids Entertainment, Inc.","","/about/listed/kde.html"],...etc.
however my code:

Code: Select all

$result = '[["TW","21st Century Insurance Group","","/about/listed/tw.html"],';
$result .= '["MMM","3M Company","","/about/listed/mmm.html"],';
$result .= '["KDE","4 Kids Entertainment, Inc.","","/about/listed/kde.html"],';
$pattern = '!\["([^"]*)","([^"]*)","([^"]*)","([^"]*)"\],!';
preg_match($pattern,$result,$test);
print_r($test);
only prints out the first "set" of information in the array like so:
Array
(
[0] => ["TW","21st Century Insurance Group","","/about/listed/tw.html"],
[1] => TW
[2] => 21st Century Insurance Group
[3] =>
[4] => /about/listed/tw.html
)

Any clues as to how to get this regex to retrieve ALL of the "sets of data" in the array I am REGEX'ing?

Posted: Mon Apr 09, 2007 12:55 am
by afbase
Guhhhhh
i found my function :)
preg_match_all()