2017 © Pedro Peláez
 

library array_column

Provides functionality for array_column() to projects using PHP earlier than version 5.5.

image

rhumsaa/array_column

Provides functionality for array_column() to projects using PHP earlier than version 5.5.

  • Sunday, January 31, 2016
  • by ramsey
  • Repository
  • 18 Watchers
  • 311 Stars
  • 384,502 Installations
  • PHP
  • 10 Dependents
  • 1 Suggesters
  • 61 Forks
  • 3 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

array_column() for PHP

Build Status Coverage Status Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

This simple library provides functionality for array_column() to versions of PHP earlier than 5.5. It mimics the functionality of the built-in function in every way., (*2)

Usage

array array_column(array $input, mixed $columnKey[, mixed $indexKey])

Given a multi-dimensional array of data, array_column() returns the values from a single column of the input array, identified by the $columnKey. Optionally, you may provide an $indexKey to index the values in the returned array by the values from the $indexKey column in the input array., (*3)

For example, using the following array of data, we tell array_column() to return an array of just the last names, indexed by their record IDs., (*4)

``` php <?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' ) );, (*5)

$lastNames = array_column($records, 'last_name', 'id');, (*6)


If we call `print_r()` on `$lastNames`, you'll see a resulting array that looks a bit like this: ``` text Array ( [2135] => Doe [3245] => Smith [5342] => Jones [5623] => Doe )

Installation

The easiest way to install this library is to use Composer:, (*7)

php composer.phar require ramsey/array_column

Then, when you run composer install, everything will fall magically into place, and the array_column() function will be available to your project, as long as you are including Composer's autoloader., (*8)

However, you do not need Composer to use this library., (*9)

This library has no dependencies and should work on older versions of PHP. Download the code and include src/array_column.php in your project, and all should work fine., (*10)

When you are ready to run your project on PHP 5.5, everything should continue to run well without conflicts, even if this library remains included in your project., (*11)

The Versions

31/01 2016

dev-master

9999999-dev https://github.com/ramsey/array_column

Provides functionality for array_column() to projects using PHP earlier than version 5.5.

  Sources   Download

MIT

The Development Requires

array column array_column

20/03 2015

1.1.3

1.1.3.0 https://github.com/ramsey/array_column

Provides functionality for array_column() to projects using PHP earlier than version 5.5.

  Sources   Download

MIT

The Development Requires

array column array_column

22/07 2013

1.1.2

1.1.2.0 https://github.com/ramsey/array_column

Provides functionality for array_column() to projects using PHP earlier than version 5.5.

  Sources   Download

MIT

array column array_column

06/07 2013

1.1.1

1.1.1.0 https://github.com/ramsey/array_column

Provides functionality for array_column() to projects using PHP earlier than version 5.5.

  Sources   Download

MIT

array column array_column

06/07 2013

1.1.0

1.1.0.0 https://github.com/ramsey/array_column

Provides functionality for array_column() to projects using PHP earlier than version 5.5.

  Sources   Download

MIT

array column array_column

23/03 2013

1.0.0

1.0.0.0 https://github.com/ramsey/array_column

Provides functionality for array_column() to projects using PHP earlier than version 5.5.

  Sources   Download

MIT

array column array_column