php5.5新增了一个新的数组函数,感觉挺使用的,低版本的实现按照如下实现

 if(!function_exists('array_column')){
function array_column($input, $columnKey, $indexKey=null){
$columnKeyIsNumber = (is_numeric($columnKey)) ? true : false;
$indexKeyIsNull = (is_null($indexKey)) ? true : false;
$indexKeyIsNumber = (is_numeric($indexKey)) ? true : false;
$result = array();
foreach((array)$input as $key=>$row){
if($columnKeyIsNumber){
$tmp = array_slice($row, $columnKey, );
$tmp = (is_array($tmp) && !empty($tmp)) ? current($tmp) : null;
}else{
$tmp = isset($row[$columnKey]) ? $row[$columnKey] : null;
}
if(!$indexKeyIsNull){
if($indexKeyIsNumber){
$key = array_slice($row, $indexKey, );
$key = (is_array($key) && !empty($key)) ? current($key) : null;
$key = is_null($key) ? : $key;
}else{
$key = isset($row[$indexKey]) ? $row[$indexKey] : ;
}
}
$result[$key] = $tmp;
}
return $result;
}
}

php5.5新函数array_column的更多相关文章

  1. php5.4新功能Traits

    php5.4新功能Traits介绍 1. traits Traits是在5.4中新增的一个用于实现代码重用的方法. php是一种单一继承的语言,我们无法像java一样在一个class中extends多 ...

  2. CREATE FUNCTION - 定义一个新函数

    SYNOPSIS CREATE [ OR REPLACE ] FUNCTION name ( [ argtype [, ...] ] ) RETURNS rettype { LANGUAGE lang ...

  3. SQL Server 2019 新函数Approx_Count_Distinct

    2019年11月4日微软发布了2019正式版,该版本有着比以往更多强大的新功能和性能上的优势,可参阅SQL Server 2019 新版本. SQL Server 2019具有一组丰富的增强功能和新功 ...

  4. 160_技巧_Power BI 新函数-计算工作日天数

    160_技巧_Power BI 新函数-计算工作日天数 一.背景 Power BI 2022 年 7 月 14 日更新了最新版本的,版本号为:2.107.683.0 . 更多更新内容可以查看官方博客: ...

  5. PHP5.3, PHP5.4, PHP5.5新特性

    PHP 5.3中的新特性 1. 支持命名空间 (Namespace) 2. 支持延迟静态绑定(Late Static Binding) 3. 支持goto语句 4. 支持闭包.Lambda/Anony ...

  6. php5.3 PHP5.4 PHP5.5 新特性/使用PHP5.5要注意的

      1.PHP 5.3中的新特性 1.1 PHP 5.3中的新特性 1.1.1. 支持命名空间 (Namespace) 毫无疑问,命名空间是PHP5.3所带来的最重要的新特性. 在PHP5.3中,则只 ...

  7. php5.3新特性 之 mysql native driver(mysqlnd)

    概述 本文主要写给sa看的.码农就不用看了. mysql native driver(mysqlnd) 自从php5.3.0开始成为官方源代码的一部分, 用来取代传统的mysql client lib ...

  8. Php5.5新特性 Generators详解

    在PHP5.5.0版本中,新增了生成器(Generators)特性,用于简化实现迭代器接口(Iterator)创建简单的迭代器的复杂性. 通过生成器,我们可以轻松的使用foreach迭代一系列的数据, ...

  9. php5 Array 数组函数

    函数 描述 array() 创建数组. array_change_key_case() 把数组中所有键更改为小写或大写. array_chunk() 把一个数组分割为新的数组块. array_colu ...

随机推荐

  1. Delphi 连接mysql 的功能, 去除乱码, 需要设置字符集

    vDataBaseName := aConfiginiFile.ReadString('DataBaseConfig', 'DataBase', CH_IPC712Db); vServer := aC ...

  2. [SQL]SQL类似统计功能的sql文

    declare @t table(name varchar(),type int) insert into @t union all union all union all union all if ...

  3. NYOJ 55-懒省事的小明

    点击打开链接 懒省事的小明 时间限制:3000 ms  |  内存限制:65535 KB 难度:3 描述       小明很想吃果子,正好果园果子熟了.在果园里,小明已经将所有的果子打了下来,而且按果 ...

  4. 推荐一个代码生成工具:freemarker

    freemarker:http://freemarker.org/ 还有velocity:http://velocity.apache.org/

  5. hive 调用java的函数和科学记数法转换

    hive中field如果是string,比如id,那么使用10000000000+id结果是科学计数法显示,转换为正常显示方法: select (10000000000+cast(id as int) ...

  6. ibatis cannot find <sql> pattern

    "Could not find SQL statement to include with refid xxx"A: 认真把每个用到xxx的地方都看一遍

  7. HDU 4771 Stealing Harry Potter's Precious

    Stealing Harry Potter's Precious Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 ...

  8. 在 Visual Studio 2013 中使用 Grunt, Bower 和 NPM

    在 Visual Studio 2015 中提供了对于 Grunt 和 Gulp 的内置支持,在 Visual Studio 2013 中怎么办呢?微软将 2015 中的特性作为几个独立的扩展发布出来 ...

  9. Unity AssetBundles and Resources指引 (三) AssetBundle基础

    本文内容主要翻译自下面这篇文章 https://unity3d.com/cn/learn/tutorials/topics/best-practices/guide-assetbundles-and- ...

  10. WEB前端研发工程师编程能力成长之路(1)(转)

    WEB前端研发工程师编程能力成长之路(1)   [背景] 如果你是刚进入WEB前端研发领域,想试试这潭水有多深,看这篇文章吧: 如果你是做了两三年WEB产品前端研发,迷茫找不着提高之路,看这篇文章吧: ...