在php中将关联数组转换为其值的简单数组
问题描述:
我想转换数组:
Array (
[category] => category
[post_tag] => post_tag
[nav_menu] => nav_menu
[link_category] => link_category
[post_format] => post_format
)
到
array(category, post_tag, nav_menu, link_category, post_format)
我试过了
$myarray = 'array('. implode(', ',get_taxonomies('','names')) .')';
回声:
array(category, post_tag, nav_menu, link_category, post_format)
所以我可以做
echo $myarray;
echo 'array(category, post_tag, nav_menu, link_category, post_format)';
它打印出完全相同的东西.
and it prints the exact same thing.
...但我不能在函数中使用 $myarray
代替手动输入的数组,因为该函数不会将其视为数组或其他东西.
...but I can't use $myarray
in a function in place of the manually entered array because the function doesn't see it as array or something.
我在这里遗漏了什么?