Not getting all the information out of an array.

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
afbase
Forum Contributor
Posts: 113
Joined: Tue Aug 15, 2006 1:29 pm
Location: SoCAL!!!!

Not getting all the information out of an array.

Post 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?
afbase
Forum Contributor
Posts: 113
Joined: Tue Aug 15, 2006 1:29 pm
Location: SoCAL!!!!

Post by afbase »

Guhhhhh
i found my function :)
preg_match_all()
Post Reply