Question

I have the following URL:
http://sub.mysite.com/store/?store=Fine+Ting&storeid=3726&test1=value1&test2=value2

Using print_r(parse_url($url)) gives me this:

Array ( 
  [scheme] => http 
  [host] => sub.mysite.com 
  [path] => /store/ 
  [query] => store=Fine+Ting& 
  [fragment] => 038;storeid=3726&test1=value1&test2=value2 
) 

According to the documentation I should only get fragment after the hashmark #.

Why then is parse_url returning fragment? Shouldn't that be in [query]?

Was it helpful?

Solution

You have a problem with you url, the ampersand is encoded in htmlentities (&). Therefore parse_str thinks, the fragment is starting there.

Try using html_entity_decode before passing the url to parse_url.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top