In my WP plugin, I need to store array from a jason file.
PHP callback retrieve $_POST[‘some key’] and return sub array json_encode(array[‘some key’]).
- First time : $my_array = json_decode(file_get_contents($filename), true)) and return json_encode(my_array)
- Second time : $my_array = my_array[$_POST[‘some key’]] return json_encode(my_array)
- Third time : $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 …