php 函数

$records= array(

array(

'id'=>2135,

'first_name'=>'John',

'last_name'=>'Doe',

),

array(

'id'=>3245,

'first_name'=>'Sally',

'last_name'=>'Smith',

),

array(

'id'=>5342,

'first_name'=>'Jane',

'last_name'=>'Jones',

),

array(

'id'=>5623,

'first_name'=>'Peter',

'last_name'=>'Doe',

)

);


$last_names=array_column($records,'last_name','id');

print_r($last_names);



以上例程会输出:

Array

(

[2135] => Doe

[3245] => Smith

[5342] => Jones

[5623] => Doe

)

你可能感兴趣的:(php 函数)