php - How do I get serialize data on wordpress -
how serialize data on wordpress database?
example
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 want call sex , use
$sex = get_option('widget_example-widget'); echo $sex['sex']; it return empty , when try var_dump result below
array(3) { [2]=> array(0) { } [6]=> array(4) { ["title"]=> string(14) "example widget" ["name"]=> string(8) "john doe" ["age"]=> string(2) "30" ["sex"]=> string(4) "male" } ["_multiwidget"]=> int(1) } actually can retrieve data add $sex['6']['sex'] problem here [6]=> dynamic. when activate/deactivate widget can in value.
question
how correct data one?
i'm not sure of want, maybe try function check every array see if "sex" index isset, , return value if is. not efficient should anyway...
Comments
Post a Comment