I'm dealing with a scrupt that for some reason can't read normal $_GET and $_POST and just reads the whole thing as a string. This is the string it reads and I'm given this as output.
?field1=value1&field2=value2&field3=value3
I'm writing a function that works with this output to break it up into its individual field1, field2, field3 values. The issue is that not all fields may be present and there's a possibility someone may add fields tha开发者_JS百科t shouldn't exist. For example I may get
?field1=value1&field3=value3 (no field2)
?field1=value1&field4=value4 (I don't even have field4)
Can this be done with a regex? or is there a better way?
Rather than use regexp, take a look at the native PHP parse_str()
function
And check if your web server is rewriting the request in any way
EDIT
Check the value of arg_separator.input in your php.ini file. I'd expect this to be commented out, or set to include & as an argument separator
精彩评论