I’m trying to get a users ID from a string such as:
http://www.abcxyz.com/123456789/
To appear as 123456789 essentially stripping the info up to the first / and also removing the end /. I did have a look around on the net but there seems to be so many solutions but nothing answering both start and end.
Thanks 🙂
Update 1
The link can take two forms: mod_rewrite as above and also “http://www.abcxyz.com/profile?user_id=123456789”
I would use
parse_url()to cleanly extract the path component from the URL:and then split the path into its elements using
explode():and then output the first component of the path:
this method will work in edge cases like
http://www.example.com/123456789?testhttp://www.example.com//123456789www.example.com/123456789/abcdefand even
/123456789/abcdef