Get support for ramsey/array_column
If you're new to LTH, please see our FAQ for more information on what it is we do.
Support Options
Unfortunately, there are currently no active helpers for this repository on the platform. Until they become available, we reccomend the following actions:
View Open IssuesTake a look to see if anyone else has experienced the same issue as you and if they managed to solve it.
Open an IssueMake sure to read any relevant guidelines for opening issues on this repo before posting a new issue.
Sponsor directlyCheck out the page and see if there are any options to sponsor this project or it's developers directly.
ramsey/array_column
array_column() for PHP
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.
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.
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.
<?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'
)
);
$lastNames = array_column($records, 'last_name', 'id');
If we call print_r()
on $lastNames
, you'll see a resulting array that looks
a bit like this:
Array
(
[2135] => Doe
[3245] => Smith
[5342] => Jones
[5623] => Doe
)
Installation
The easiest way to install this library is to use Composer:
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.
However, you do not need Composer to use this library.
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.
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.
Our Mission
We want to make open source more sustainable. The entire platform was born from this and everything we do is in aid of this.
From the Blog
Interesting Articles
-
Generating income from open source
Jun 23 • 8 min read
-
2023 State of OSS
Apr 23 • 45 min read ★
-
A funding experiment...
Aug 19 • 10 min read
-
But You Said I could
Aug 19 • 2 min read
Thank you for checking out LiveTechHelper |
2025 © lth-dev incorporated
p-e622a1a2