gladideg Posted June 8, 2009 Share Posted June 8, 2009 I have a long URL with lots of stuff in it, and many slashes. I need to get whatever value that is after the last slash. I've tried different techniques, but I'm totaly lost and got a brain carpet atm. Anyone could give me a hand here? http://blabla.com:2995/sjj43_defin/super/30210014003410301031 <- I need the bold values. :-\ Quote Link to comment https://forums.phpfreaks.com/topic/161409-solved-regex-get-anything-after-last-forward-slash/ Share on other sites More sharing options...
thebadbad Posted June 8, 2009 Share Posted June 8, 2009 Using the simple string functions would be fastest: <?php $str = 'http://blabla.com:2995/sjj43_defin/super/30210014003410301031'; echo substr(strrchr($str, '/'), 1); ?> strrchr($str, '/') returns everything after the last slash, including the slash (/30210014003410301031) substr('/30210014003410301031', 1) cuts the first char off Quote Link to comment https://forums.phpfreaks.com/topic/161409-solved-regex-get-anything-after-last-forward-slash/#findComment-851775 Share on other sites More sharing options...
gladideg Posted June 8, 2009 Author Share Posted June 8, 2009 Great. that works perfect. Thank you for helping. Quote Link to comment https://forums.phpfreaks.com/topic/161409-solved-regex-get-anything-after-last-forward-slash/#findComment-851855 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.