在php中将关联数组转换为其值的简单数组 [英] Convert an associative array to a simple array of its values in php
本文介绍了在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.
我在这里遗漏了什么?
推荐答案
只需使用 array_values
函数:
simply use array_values
function:
$array = array_values($array);
这篇关于在php中将关联数组转换为其值的简单数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文