0
我得到了WordPress的一个PHP函数,得到序列化用户的元数据:像这样函数返回数组返回NULL
function get_allowwed_tournees_ids(){
$tournees = get_user_meta($this->ID, 'tournees',true);
$tournees = unserialize($tournees);
$tournees_ids = array();
foreach ($tournees as $key => $value) {
array_push($tournees_ids, $key);
}
var_dump($tournees_ids);
return $tournee_ids;
}
get_allowwed_tournees_ids()是在扩展WP_User 一类,当我想称之为:
$id_tournees = $current_user->get_allowwed_tournees_ids();
var_dump($id_tournees);
该函数内的var_dump返回的是未经序列化的数组,而该函数外的第二个var_dump返回null。
任何想法??谢谢 !
你不需要使用反序列化我猜coz get_usermeta函数返回你阵列或多维数组。 – Pranita