How to update the options table for a widget

An array will be serialized when saved to the DB. If you want to update a key to the array, you need to

  • Fetch the option first
  • Apply modifications
  • Update the option with the updated array values

so in your example if you fetch the option, you should get a multidimensional array where you have a key => value of How to update the options table for a widget => Widget Title you would update that title key with your new value and then update back your option.

Something like this

$my_option = get_option( 'your_option_name' );

now let’s say your key is in the first dimension of the array, then you update your value there.

$my_option['title'] = 'New Widget Title';

and finally you update your options back to the DB.

update_option( 'your_option_name', $my_option );