Part of my script involves conditionally calling parse_str() on a function parameter. I've just realised that the reason why the function isn't working is that, because parse_str() is called as the conditional expression in an if statement, the resulting variables only exist in that block:
if (!$force_reload) parse_str($data);
After this statement the variables created by parse_str() no longer exist (right?).
I checked the docs and apparently I can get parse_str() to store the results in array:
$data_array = array();
if (!$force_reload) parse_str($data, $data_array());
echo($data_array['name']);
etc.
but if there was a way of conditionally calling parse_str() and keeping the variables in scope it would mean that I wouldn't have to change the rest of the function.
Is that possible?
Cheers,
Richard