I export a variable to a textarea via “var_export($schools,true)” so user can edit it. Then I want to ‘update’ the variable with the changes made. The updates is received via POST method.
I have some text that I want to become a variable. How can I do that?
What I do right now is that I edit the variable manually in .php file. I want to give an web interface to users do to the same. There won’t be no security issues as this will be strictly inhouse tool only.
Sample of the variable
$schools = array(
"PHCS"=> array(
"full_name"=> "Pacific Hills Christian School",
"version"=> "4.0.2b",
"etc"=> "etc"
),
"WAC"=> array(
"full_name"=> "Wollondilly Anglican College",
"version"=> "4.0.1",
"etc"=> "etc"
),
);
You would be looking at using
eval()which use of is pretty controversial due to security risks.I would suggest you use
serialize()andunserialize(), or even better, the JSON functions instead.The JSON encode/decode would be the best option for displaying to the user as it’s fairly readable.