码迷,mamicode.com
首页 > Web开发 > 详细

php函数 array_column

时间:2019-04-13 10:34:05      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:技术   php   ima   这一   ram   mamicode   span   param   bsp   

<?php

$arr = [
	[
		‘id‘=>1,
		‘name‘=>‘wang‘,
		‘age‘=>10
	],
	[
		‘id‘=>2,
		‘name‘=>‘yong‘,
		‘age‘=>28
	],
	[
	‘id‘=>3,
	‘name‘=>‘shun‘,
	‘age‘=>33
]
];


$arr1 = array_column($arr,‘name‘,‘age‘);
$arr2 = array_column($arr,‘name‘);

echo ‘<pre>‘;
print_r($arr1);

echo ‘<pre>‘;
print_r($arr2);

 

array_column() 返回input数组中键值为column_key的列, 如果指定了可选参数index_key,那么input数组中的这一列的值将作为返回数组中对应值的键。

 

 

 

 

技术图片

 

php函数 array_column

标签:技术   php   ima   这一   ram   mamicode   span   param   bsp   

原文地址:https://www.cnblogs.com/php-linux/p/10699864.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!