|
-
Apr 12th, 2006, 01:27 AM
#1
Thread Starter
Junior Member
PHP parsing Problem
Hey, was looking for a bit of php help for a page I'm making. Just as a note I'm learning php currently but I'm not great at it so any help would be great.
Heres what I want to do;
the page URL is:http://www.whatever.com/whatever.php/123
now I'm trying to make a php program that will grab the path info, so what's in the URL bar and parse out 123, or for that matter any other number that is at the end. Then simply input it into a variable called $newsart. I've tried a few different ways and have been told that in newer version of php the function for grabbing that path info has changed. Does anyone have any suggestions?
-script
-
Apr 12th, 2006, 09:35 PM
#2
Thread Starter
Junior Member
Re: PHP parsing Problem
Is there not a way of doing this?
-
Apr 12th, 2006, 10:01 PM
#3
Frenzied Member
Re: PHP parsing Problem
Try like:
PHP Code:
$url = "http://www.whatever.com/whatever.php/123";
$parts = explode($url, "/");
$number = $parts[sizeof($parts)];
print $number;
I wrote that by hand, so test it out
Age - 15 ::: Level - Advanced
If you find my post useful please ::Rate It::

-
Apr 12th, 2006, 10:10 PM
#4
Thread Starter
Junior Member
Re: PHP parsing Problem
Alright but I need a way to grab the numbers from the URL no matter what they are.
-script
-
Apr 12th, 2006, 10:14 PM
#5
Frenzied Member
Re: PHP parsing Problem
That does. Explode splits a string up depending on a certain element, like "/" and returns all the parts in an array. The last part would be the number, because it's after the last "/", and sizeof returns the number of elements an array holds, thus we are getting the last element from the array, which is the number.
Age - 15 ::: Level - Advanced
If you find my post useful please ::Rate It::

Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|