How do you get serialize data using blogging platforms database?


option_name               option_value
widget_example-widget     a:3:{i:2;a:0:{}i:6;a:4:{s:5:"title";s:14:"Example Widget";s:4:"name";s:8:"John Doe";s:3:"age";s:2:"30";s:3:"sex";s:4:"male";}s:12:"_multiwidget";i:1;}

Example I wish to call sex and that i use

$sex = get_option('widget_example-widget');
echo $sex['sex'];

It return empty so when try var_dump result like below

array(3) {
  array(0) {
  array(4) {
    string(14) "Example Widget"
    string(8) "John Doe"
    string(2) "30"
    string(4) "male"

Really I'm able to retrieve this data by add $sex['6']['sex'] the main problem here the [6]=> is dynamic. Whenever we activate/deactivate the widget it may be in another value.


How do you obtain a correct data for that one?

I am unsure of the items you want, but maybe consider using a function that check every array to ascertain if "sex" index isset, and return the worthiness if it's. Not so efficient however it must do it anyway...