Hi guys, I'm having a little trouble, I've tried a few things but I can't get what I want.
I have the following data:
As you can see, One of the names of the links are different. I just want to match the name and the user ID.Code:<a href="/profile.php?id=34214" class="slink">User Abcd</a> <a href="/profile.php?id=34243" class="slink">User Abcdef</a> <a href="/profile.php?id=34213" class="slink">User Abcdefgh</a> <a href="/profile.php?id=34214" class="slink">User Abcdefghij <small><sup>*</sup></small></a> <a href="/profile.php?id=34211" class="slink">User Abcdefghijklm</a>
I have tried the following:
It works fine, Appart from it also returns the <small> etc... (Which is what it's supposed to return)PHP Code:preg_match_all("<a href=\"\/profile.php\?id=(\d+)\" class=\"slink\">(.*?)<\/a>"......
But, I don't want that, How do I just not include it? As you see, it's not always there.
The following works, but not as expected:
PHP Code:preg_match_all("<a href=\"\/profile.php\?id=(\d+)\" class=\"slink\">((\w+) .*?|(\w+))<\/a>"......
Hope you understand what i'm trying to get to.Code:Array ( [0] => <a href="/profile.php?id=34213" class="slink">User Abcdefgh</a> [1] => 34213 [2] => User Abcdefgh [3] => [4] => User Abcdefgh ) Array ( [0] => <a href="/profile.php?id=34214" class="slink">User Abcdefghij <small><sup>*</sup></small></a> [1] => 34214 [2] => User Abcdefghij <small><sup>*</sup></small> [3] => User Abcdefghij )
Thanks.


Reply With Quote
