1

I will have a php query string of the following pattern:

?x=a&y=b&z=c

with possibly more parameters after the "?". The x,y,z values will only consist of characters between aA-zZ. the a,b,c values, however, can literally be anything. They may also include & characters or = characters. Is there any way to split the x=a patterns by considering both regex and the delimiter & and place them into an associate array such as the following:

$values = array(x => a, y => b, z => c); 

Edit:

I think I should clarify. x can be a value such as note. whereas a, b, c can be values such as http://yay.com/wahoo?wahoo=3&zahoo=5.

snehoozle
  • 273
  • 2
  • 4
  • 14

1 Answers1

0

As scrowler wrote, parse_str() might do the trick, HOWEVER, if values "may also include & characters or = characters", how would you say if ?x=a&y=b&z=c should be parsed as:

$values = array(x => a, y => b, z => c); or rather:

$values = array(x => a&y=b, z => c);

or: $values = array(x => a&y=b&z=c);

I guess the "&" and "=" characters will be escaped in some way, for example using percent escaping.

Lukasz Czerwinski
  • 13,499
  • 10
  • 55
  • 65