我有一個關聯數組,看起來像這樣:返回關聯數組的所有鍵與功能
Array (
[0] => Array ()
[1] => Array ()
[2] => Array ([318] => 3.3333333333333)
[3] => Array ()
[4] => Array ()
[5] => Array ([317] => 5)
)
我想返回數組數,而不是字符串的所有數組鍵;那就是爲什麼我不迴應它。這是我正在嘗試:
function user_rated_posts(){
global $author;
if(isset($_GET['author_name'])) :
$curauth = get_userdatabylogin($author_name);
else :
$curauth = get_userdata(intval($author));
endif;
$user_rated_posts = get_user_meta($curauth->ID, 'plgn_rating',true);
foreach ($user_rated_posts as $arrs){
foreach($arrs as $key=> $value){
$keys= $key;
}
}
return $keys;
}
當我打電話這樣的功能:
array(explode(',',user_rated_posts()))
我只得到這個
array(317)
我試圖讓所有的鍵逗號分隔格式,如:
array(318, 317)
謝謝。
'$鍵[] = $鍵;' – moonwave99