I would like to convert the array:
我想要转换数组:
Array (
[category] => category
[post_tag] => post_tag
[nav_menu] => nav_menu
[link_category] => link_category
[post_format] => post_format
)
to
来
array(category, post_tag, nav_menu, link_category, post_format)
I tried
我试着
$myarray = 'array('. implode(', ',get_taxonomies('','names')) .')';
which echos out:
这回声报:
array(category, post_tag, nav_menu, link_category, post_format)
So I can do
所以我能做的
echo $myarray;
echo 'array(category, post_tag, nav_menu, link_category, post_format)';
and it prints the exact same thing.
它打印的是一样的东西。
...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.
…但是我不能在函数中使用$myarray来代替手动输入的数组,因为函数不把它看作数组或其他东西。
What am I missing here?
我错过了什么?
2 个解决方案
#2
6
You should use the array_values()
function.
应该使用array_values()函数。
#1
#2
6
You should use the array_values()
function.
应该使用array_values()函数。