N-Bomb(Nerd) Posted January 23, 2012 Share Posted January 23, 2012 Hello, I have a string like such: http://logs.coolbeans.net/character/name/QAkHcdcSSjLfus I'm trying to get the content after the last "/" (in this case: QAkHcdcSSjLfus). I tried using this as my expression, but it failed me "~http\://logs\.coolbeans\.net/character/name/(.*?)~". When doing if(preg_match("~http\://logs\.coolbeans\.net/character/name/(.*?)~", $string, $results) the if expression is true, but $results won't contain the value I want. How do I do this? Thanks. Link to comment https://forums.phpfreaks.com/topic/255585-getting-last-url-content/ Share on other sites More sharing options...
trq Posted January 23, 2012 Share Posted January 23, 2012 Your probably better off using parse_url and basename. Link to comment https://forums.phpfreaks.com/topic/255585-getting-last-url-content/#findComment-1310272 Share on other sites More sharing options...
N-Bomb(Nerd) Posted January 23, 2012 Author Share Posted January 23, 2012 basename() works perfectly! Thanks!. Link to comment https://forums.phpfreaks.com/topic/255585-getting-last-url-content/#findComment-1310278 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.