I am using this to get a string from jquery to a php array via json.
$navMenuLayout = array();
parse_str($layout['navMenu'], $navMenuLayout);
print_r($navMenuLayout);
But I noticed if I take out the first line then I still get the same output, does the first line matter?
parse_str($layout['navMenu'], $navMenuLayout);
print_r($navMenuLayout);
Of course, you don’t have to predefine the variable for this function because PHP sets them automatically.
See the example from PHP.net for what happens when the second argument is defined/undefined:
So, if you don’t define the second argument, each key=>value pair in the string is made into an actual variable, whereas if you define a variable to be set, they are put into an array as that variable. PHP will automatically create everything for the function, you don’t have to pre-define anything.