PHP read Array and Object
I got this array and I want to read the value of "copy01"
(in img_4e77e508ab518_197.jpg
).
Array ( [0] => stdClass Object ( [meta_value] => O:8:"stdClass":3:{s:6:"copy01";s:25:"img_4e77e508ab518_197.jpg";s:6:"copy02";s:24:"img_4e77e508ab518_80.jpg";s:6:"copy0开发者_运维百科3";s:24:"img_4e77e508ab518_36.jpg";} ) )
This is a print_r($dataOne)
and $data_One
is a query from the database in WP.
$dataOne = $wpdb->get_results("SELECT meta_value FROM usermeta WHERE umeta_id = '22'");
echo unserialize($dataOne[0]->meta_value)->copy01;
You have an array with a serialized object as the 0th element of the array.
$normalobject = unserialize($dataOne[0]);
and var_dump($normalobject);
to get an idea of how to read the value.
$dataOne[0]->copy01
how about that?
精彩评论