using parse_url is returning only the first arg=value for $a['query'].  How do we get all elements?

Posted on 2005-05-10
Medium Priority
Last Modified: 2008-03-17
We are using parse_url to decode a url into its components.

The function is working correctly except that it is returning only the first url variable.
For instance if we do:

$a['query'] returns only up to "pro=w".  We need it to return all elements of the request.  How do we do this?

Question by:mcm-mgm
1 Comment
LVL 27

Accepted Solution

Diablo84 earned 1000 total points
ID: 13973471
hmm, don't know why you are seeing that output,

$a = parse_url('http://www.futureshop.ca/catalog/proddetail.asp?pro=w&langid=EN&dept=3&sku_id=0665000FS10048110&catid=11130&newdeptid=15');

echo '<pre>';
echo '</pre>';


    [scheme] => http
    [host] => www.futureshop.ca
    [path] => /catalog/proddetail.asp
    [query] => pro=w&langid=EN&dept=3&sku_id=0665000FS10048110&catid=11130&newdeptid=15

Which is correct.

Failing that you can get the current query string contents using: $_SERVER['QUERY_STRING']

or, if you need to get it from a string URL rather then the current one you could use:

$url = 'http://www.futureshop.ca/catalog/proddetail.asp?pro=w&langid=EN&dept=3&sku_id=0665000FS10048110&catid=11130&newdeptid=15';
echo substr($url,strpos($url,'?')+1);


Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses
Course of the Month16 days, 17 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question