我使用了这个wordpress功能
$all_meta_for_user = get_user_meta( $user->ID );
$city = $all_meta_for_user['dokan_profile_settings'][0];
print_r( $city );
这就是我得到的
a:11:{s:10:“商店名称”; s:14:“ test_trioszhrt”; s:6:“社交”; a:0:{} s:7:“付款”; a:0: {} s:5:“电话”; s:8:“ 12541025”; s:10:“ show_email”; s:2:“否”; s:7:“地址”; a:6:{s:8 :“ street_1”; s:8:“ kkloadaa”; s:8:“ street_2”; s:0:“”; s:4:“ city”; s:7:“突尼斯”; s:3:“ zip “; s:1:” 1“; s:7:”国家“; s:2:” NP“; s:5:”州“; s:3:” GAN“;} s:8:”位置“ ; s:0:“”; s:6:“横幅”; i:0; s:12:“ find_address”; s:0:“”; s:14:“ dokan_category”; s:0:“”; s:9:“ store_ppp”; i:10;}
我只想得到城市? 我该怎么做?
答案 0 :(得分:3)
这是一个serialize
d字符串。 unserialize
转换为php值(在本例中为 array )并使用:
$s = 'a:11:{s:10:"store_name";s:14:"test_trioszhrt";s:6:"social";a:0:{}s:7:"payment";a:0:{}s:5:"phone";s:8:"12541025";s:10:"show_email";s:2:"no";s:7:"address";a:6:{s:8:"street_1";s:8:"kkloadaa";s:8:"street_2";s:0:"";s:4:"city";s:7:"tunisia";s:3:"zip";s:1:"1";s:7:"country";s:2:"NP";s:5:"state";s:3:"GAN";}s:8:"location";s:0:"";s:6:"banner";i:0;s:12:"find_address";s:0:"";s:14:"dokan_category";s:0:"";s:9:"store_ppp";i:10;}';
$data = unserialize($s);
print_r($data);
echo $data['address']['city'];