I need to return the NewsID numeric value of 60 from this string mysite/details.php?NewsId=60&sweetid=2791992
I have to use $_GET["returnurl"] ; to return the url but I’m really not sure what is the best way to strip this string to just find the value of ‘60’ especially as this number could grow to 100's or more digits as the cart grows.
Can anyone suggest what I can do and what is the best way to strip this without problems later on?
Thank you
[Solved] striping a URL
Moderator: General Moderators
[Solved] striping a URL
Last edited by Addos on Wed Apr 23, 2008 5:09 pm, edited 1 time in total.
- EverLearning
- Forum Contributor
- Posts: 282
- Joined: Sat Feb 23, 2008 3:49 am
- Location: Niš, Serbia
Re: striping a URL
If I understood what you want correctly, you can use parse_str() and parse_url() to get what you need
Code: Select all
$url = 'mysite/details.php?NewsId=60&sweetid=2791992';
$info = parse_url($url);
parse_str($info['query'], $output);
echo $output['NewsId'];Re: striping a URL
Thank you very much that worked a treat and I never knew it existed.
Thanks again.
Thanks again.