As far WordPress is concerned – your multi-dimensional array is one option. To update just part of the multi-dimensional array its necessary to retrieve the entire array, alter it accordingly and then update the entire array.
Suppose your multi-dimensional array is as follows:
1 2 3 4 5 6 7 8 9 | my_options = array( 'option_a'=>'value_a', 'option_b'=>'value_b', 'inner_array'=>array( 'foo' => 'bar', 'hello' => 'world', ), 'option_c'=>'value_c' ) |
And suppose you want to update the value of the ‘hello’ option from ‘world’ to ‘moon’
1 2 3 4 5 6 7 8 | //Get entire array $my_options = get_option('my_options'); //Alter the options array appropriately $my_options['inner_array']['hello'] = 'moon'; //Update entire array update_option('my_options', $my_options); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.