In my WP plugin, I need to store array from a jason file.
PHP callback retrieve $_POST['some key']
and return to jquery ajax echo sub array json_encode(array['some key'])
.
- First time :
$my_array = json_decode(file_get_contents($filename), true))
and return to jquery ajax echojson_encode(my_array)
- Second time :
$my_array = my_array[$_POST['some key']] return to jquery ajax echo json_encode(my_array)
- Third time :
<code>$my_array = my_array[$_POST['some other key']] return json_encode(my_array)</code><code>$my_array = my_array[$_POST['some other key']] return json_encode(my_array) </code>$my_array = my_array[$_POST['some other key']] return json_encode(my_array)
How to store value of my_array to avoid global variable ? I read that global variable is not a good way. It’s same with $filename
…
1