龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

php 原生态,返回数组的的某一列或者某几列的的写法

时间:2014-07-15 15:04来源:网络整理 作者:网络 点击:
分享到:
原生态,返回数组的的某一列或者某几列的的写法 [代码片段(31行)]
<?php
//  获得纪录的数据
//这个是php最新的一个数组函数 
$records = array(
    array(
        'id' => 0,
        'pre' => 2,
        'next' => 6,
    ),
    array(
        'id' => 1,
        'pre' => 13,
        'next' => 18,
    ),
    array(
        'id' => 3,
        'pre' => 3,
        'next' => 8,
    ),
    array(
        'id' => 4,
        'pre' => 0,
        'next' => 5,
    )
);

$all_pre = array_column($records, 'pre');
//打印出所有的前驱节点
print_r($all_pre);
?>
//该片段来自于http://outofmemory.cn
精彩图集

赞助商链接