在PHP中只有一個數組中的選定鍵及其值的最簡單方法是什麼? 舉例來說,如果我有一個數組:PHP - 只用現有數組中的選定鍵創建新陣列
$meta = [
"nickname" => [
0 => "John"
]
"first_name" => [
0 => "John"
]
"last_name" => [
0 => "Doe"
]
"description" => array:1 [
0 => ""
]
"rich_editing" => [
0 => "true"
]
"comment_shortcuts" => [
0 => "false"
]
"admin_color" => [
0 => "fresh"
]
"use_ssl" => array:1 [
0 => "0"
]
"show_admin_bar_front" => [
0 => "true"
]
"locale" => [
0 => ""
]
"wp_capabilities" => [
0 => "a:1:{s:10:"subscriber";b:1;}"
]
"wp_user_level" => [
0 => "0"
]
"dismissed_wp_pointers" => [
0 => ""
]
"department" => [
0 => "Administrasjon"
]
"region" => [
0 => "Oslo"
]
"industry" => [
0 => "Bane"
]
]
什麼是獲得與例如像nickname
,first_name
,last_name
等只選擇鍵一個新的數組最簡單的方法?
@Martijn的問題是如何獲得這些鍵的值。 https://stackoverflow.com/questions/12887322/get-only-the-array-elements-with-certain-keys – tilz0R
選定的鍵是固定的還是動態的? –
他們是固定@KOUSIKMANDAL – Leff