newb Posted May 11, 2011 Share Posted May 11, 2011 <a href="user/237960-admin" class="username online" how can i make it so i can grab only the username out of this? Quote Link to comment Share on other sites More sharing options...
gizmola Posted May 11, 2011 Share Posted May 11, 2011 what part of that string is the username? Quote Link to comment Share on other sites More sharing options...
newb Posted May 11, 2011 Author Share Posted May 11, 2011 'admin' Quote Link to comment Share on other sites More sharing options...
JAY6390 Posted May 11, 2011 Share Posted May 11, 2011 if (preg_match('%<a href="user/\d+-([^"]+)"%', $subject, $matches)) { $result = $matches[1]; } else { $result = ""; } Quote Link to comment Share on other sites More sharing options...
newb Posted May 11, 2011 Author Share Posted May 11, 2011 thanks, that above code works, but it ignores the 'class="username online"' bit. i included it at the end Quote Link to comment Share on other sites More sharing options...
JAY6390 Posted May 11, 2011 Share Posted May 11, 2011 fair enough. didn't think you'd need that if you have it only matching url's that start user/000000-username but yeah you can add that bit on too if you like 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.