如何获得"子阵"在PHP中的数组? [英] How to get "sub-array" from an array in PHP?
本文介绍了如何获得"子阵"在PHP中的数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可能已经措辞的问题错了,请随时编辑它一个更好的版本。
I have probably worded the question wrong, please feel free to edit it for a better version.
我正在寻找一种方式来做到这一点:
I'm looking for a way to do this:
我有一个数组,如:
$ray=array();
$ray[0] = array();
$ray[0]['id'] = "1";
$ray[0]['name'] = "lorem";
$ray[1] = array();
$ray[1]['id'] = "2";
$ray[1]['name'] = "ipsum";
和我想要得到的名称数组,这样
and I want to get an array of names, so that
$names[0] = "lorem"
$names[1] = "ipsum"
我想我可以通过的foreach
做到这一点'ING和手动创建数组,但我不知道是否有这个内置的功能。
I think I can do this by foreach
'ing and creating the array manually, but I wonder if there is a built-in function for this.
感谢您的帮助!
推荐答案
版本PHP 4> =
Version PHP 4 >=
$finalarray = array_map(create_function('$yourarray', 'return $yourarray["arrayindex"];'), $actualarray );
这篇关于如何获得"子阵"在PHP中的数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文