从多级数组创建特定元素的数组

时间:2014-09-11 23:34:28

标签: php arrays multidimensional-array

我在变量中存储了一个值,value是一个多级数组。现在我想从该多级数组创建一个元素的新数组。

多级数组是

Array ( [0] => Array ( [file_name] => 2414_Stomach.jpg [file_type] => image/jpeg [file_path] => C:/xampp/htdocs/mobile/uploads/tmp_files/ [full_path] => C:/xampp/htdocs/mobile/uploads/tmp_files/2414_Stomach.jpg [raw_name] => 2414_Stomach [orig_name] => 2414_Stomach.jpg [client_name] => 2414_Stomach.jpg [file_ext] => .jpg [file_size] => 465.53 [is_image] => 1 [image_width] => 1122 [image_height] => 741 [image_type] => jpeg [image_size_str] => width="1122" height="741" ) [1] => Array ( [file_name] => 907302_556430127722057_954171705_n.jpg [file_type] => image/jpeg [file_path] => C:/xampp/htdocs/mobile/uploads/tmp_files/ [full_path] => C:/xampp/htdocs/mobile/uploads/tmp_files/907302_556430127722057_954171705_n.jpg [raw_name] => 907302_556430127722057_954171705_n [orig_name] => 907302_556430127722057_954171705_n.jpg [client_name] => 907302_556430127722057_954171705_n.jpg [file_ext] => .jpg [file_size] => 132.98 [is_image] => 1 [image_width] => 674 [image_height] => 960 [image_type] => jpeg [image_size_str] => width="674" height="960" ) [2] => Array ( [file_name] => 1554470_695025487195853_1418731925_n.jpg [file_type] => image/jpeg [file_path] => C:/xampp/htdocs/mobile/uploads/tmp_files/ [full_path] => C:/xampp/htdocs/mobile/uploads/tmp_files/1554470_695025487195853_1418731925_n.jpg [raw_name] => 1554470_695025487195853_1418731925_n [orig_name] => 1554470_695025487195853_1418731925_n.jpg [client_name] => 1554470_695025487195853_1418731925_n.jpg [file_ext] => .jpg [file_size] => 7.39 [is_image] => 1 [image_width] => 200 [image_height] => 200 [image_type] => jpeg [image_size_str] => width="200" height="200" ) )

现在我需要一个包含所有[file_name]元素的数组。

1 个答案:

答案 0 :(得分:0)

$new_array = array_map(function($a) { return $a['file_name']; }, $array);