I'm using preg_match_all to get the quoted users from a post on a forum like so:
preg_match_all('/quote author=(.*) link=/', $post, $quotedUsers);
The $post string will typically be something like:
[quote author=John link=topic=1234.msg123456#msg123456 date=1234567890]Lorem ipsum dolor sit amet[/quote]
Lorem ipsum dolor sit amet consectetur elit...
The preg_match_all function works fine when only one user is quoted, and returns something like:
Array
(
[0] => Array
(
[0] => quote author=John link=
)
[1] => Array
(
[0] => John
)
)
My code loops through each $quotedUsers[1] to get the usernames, and I thought everything was fine. Except, when two users are quoted, it looks more like this:
Array
(
[0] => Array
(
[0] => quote author=Bob link=topic=1234.msg123456#msg13456 date=1234567890]Lorem ipsum dolor sit amet[/quote]
[quote author=John link=
)
[1] => Array
(
[0] => Bob link=topic=1234.msg123456#msg13456 date=1234567890]Lorem ipsum dolor sit amet[/quote]
[quote author=John
)
)
What is going on and how do I fix this? I thought preg_match_all would just put all of the usernames into the $quotedUsers[1] array.