PHP 5

array_column doesn't work with an array of objects. Use array_map instead:

$titles = array_map(function($e) {
    return is_object(e->Title : $e['Title'];
}, $records);

PHP 7

array_column()

The function now supports an array of objects as well as two-dimensional arrays. Only public properties are considered, and objects that make use of __get() for dynamic properties must also implement __isset().

See https://github.com/php/php-src/blob/PHP-7.0.0/UPGRADING#L629 - Thanks to Bell for the hint!

Answer from Daniel W. on Stack Overflow
🌐
W3Schools
w3schools.com › php › func_array_column.asp
PHP array_column() Function
The array_column() function returns the values from a single column in the input array.
🌐
PHP
php.net › manual › en › function.array-column.php
PHP: array_column - Manual
A list whose rows are arrays or objects, from which a column of values is pulled. If a row is an object, public properties are read directly.
Discussions

PHP. Is it possible to use array_column with an array of objects - Stack Overflow
Is it possible to pass in array_column an array of objects? I have implemented ArrayAccess interface, but it has no effect. Should I implement another one? class Foo implements ArrayAccess { ... More on stackoverflow.com
🌐 stackoverflow.com
Using array_column in a multidimensional array.
Find answers to Using array_column in a multidimensional array. from the expert community at Experts Exchange More on experts-exchange.com
🌐 experts-exchange.com
August 9, 2020
In php is there a function like array_column for multidimensional arrays - Stack Overflow
Is there function that works similar to array_column for multidimensional arrays? Is there a function that translates the first array below to the second: Array ( [0] => Array ( ... More on stackoverflow.com
🌐 stackoverflow.com
What is the performance difference between column arrays and point source PA speakers?
The main difference is coverage pattern. The Evolve 50 has a H/V of 120°x40° whereas the ZLX series is only 90°x60°. That will make a whole lot of difference in wide venues. The LF driver in the Evolve is only 12”, but with the benefit of a ported enclosure that might enhance the LF. More on reddit.com
🌐 r/livesound
6
1
July 13, 2023
🌐
Reintech
reintech.io › blog › a-complete-guide-to-php-array-column-function
A Complete Guide to PHP's `array_column()` Function
Note: The function only accesses public properties. If your objects use private or protected properties, you'll need to implement getters or use alternative methods like array_map() with callbacks. By passing null as the $columnKey, you can re-index an array without extracting a specific column.
🌐
GeeksforGeeks
geeksforgeeks.org › php › php-array_column-function
PHP | array_column() Function - GeeksforGeeks
September 29, 2021 - The array_column() is an inbuilt function in PHP and is used to return the values from a single column in the input array.
🌐
GitHub
github.com › ramsey › array_column
GitHub - ramsey/array_column: Provides functionality for array_column() to projects using PHP earlier than version 5.5. · GitHub
January 8, 2019 - Given a multi-dimensional array of data, array_column() returns the values from a single column of the input array, identified by the $columnKey.
🌐
Scaler
scaler.com › home › topics › php array_column() function
PHP array_column() Function - Scaler Topics
April 1, 2024 - Explanation In this example, we ... names. The array_column() function is used to extract the last names from the $users array and create an associative array where the IDs serve as keys and the corresponding last names are the values....
🌐
Educative
educative.io › answers › what-is-the-arraycolumn-method-in-php
What is the array_column() method in PHP?
The array_column method will return an array with values as the retrieved column and possibly an index that is another column’s value in the targeted array.
Find elsewhere
🌐
daily.dev
daily.dev › home › php dev › a complete guide to php's `array_column()` function
A Complete Guide to PHP's `array_column()` Function | daily.dev
October 2, 2025 - PHP's array_column() function extracts a single column from multi-dimensional arrays or arrays of objects. The function accepts an input array, a column key to extract, and an optional index key for the resulting array.
🌐
Substrakt
substrakt.com › resources › simplify-your-loops-with-array_column
Simplify your loops with array_column | Substrakt
Using array_column reduces the number of lines of code you have to write, and the complexity of your code, which can only be a good thing.
🌐
OnlinePHP
onlinephp.io › array-column › manual
array_column - OnlinePHP.io Example
A multi-dimensional array or an array of objects from which to pull a column of values from. If an array of objects is provided, then public properties can be directly pulled.
🌐
Edd Mann
eddmann.com › posts › an-array-column-re-indexing-trick-in-php
An 'array_column' re-indexing trick in PHP - Edd Mann
June 8, 2016 - $arr = [ ['id' => 123, 'name' => 'Joe'], ['id' => 345, 'name' => 'Sally'] ]; array_column($arr, null, 'id'); // [ 123 => ['id' => 123, 'name' => 'Joe'] ...
🌐
Codecademy
codecademy.com › docs › php › arrays › array_column()
PHP | Arrays | array_column() | Codecademy
August 26, 2023 - The array_column() function returns the values from a single column in the input array.
🌐
ZetCode
zetcode.com › php-array › array-column
PHP array_column - Array Column Extraction in PHP
The PHP array_column function extracts a single column from a multi-dimensional array or an array of objects.
Top answer
1 of 4
4

No, there is not a function to get your expected output natively, though you can make your own functions, just use array_column to get the types/column, and then loop over your array, on match remove the item as to not duplicate iterations.

Something like:

<?php
$data = [
    ['foodType' => 'fruits', 'itemID' => 1, 'itemName' => 'apple'],
    ['foodType' => 'fruits', 'itemID' => 2, 'itemName' => 'banana'],
    ['foodType' => 'veggies', 'itemID' => 3, 'itemName' => 'carrot'],
    ['foodType' => 'veggies', 'itemID' => 4, 'itemName' => 'broccoli']
];

function array_column_multi ($array, $column) {
    $types = array_unique(array_column($array, $column));

    $return = [];
    foreach ($types as $type) {
        foreach ($array as $key => $value) {
            if ($type === $value[$column]) {
                unset($value[$column]);
                $return[$type][] = $value;
                unset($array[$key]);
            }
        }
    }
    return $return;
}


print_r(array_column_multi($data, 'foodType'));

https://3v4l.org/KQVeN

Result:

Array
(
    [fruits] => Array
        (
            [0] => Array
                (
                    [itemID] => 1
                    [itemName] => apple
                )

            [1] => Array
                (
                    [itemID] => 2
                    [itemName] => banana
                )

        )

    [veggies] => Array
        (
            [0] => Array
                (
                    [itemID] => 3
                    [itemName] => carrot
                )

            [1] => Array
                (
                    [itemID] => 4
                    [itemName] => broccoli
                )

        )

)
2 of 4
1

Oh I just noticed that you're aggregating them by ID. There's not a function for that, you're going to need to iterate over the input with a loop, and populate an output array with the data you want. Eg:

$output = [];

foreach($input_array as $item) {
  $output[$item['id']][] = [
     'itemID' => $item['itemID'],
     'itemName' => $item['itemName']
  ];
}
🌐
PHP.Watch
php.watch › codex › array_column
array_column Function • PHP.Watch
Return the values from a single column in the input array.
🌐
Phpdoctest
phpdoctest.github.io › en › function.array-column.html
PHP Manual: Return the values from a single column in the input array
Return the values from a single column in the input array · array_column returns the values from a single column of the input, identified by the column_key. Optionally, an index_key may be provided to index the values in the returned array by the values from the index_key column of the input array
🌐
Bose Professional
boseprofessional.com › products › loudspeakers › line columns
Line Columns | Bose Professional
Bose Professional column line arrays are specially engineered to excel in speech intelligibility and musicality, even in acoustically challenging spaces. Their modular design allows easy stacking and linking of modules. Lengthening the array results in extended coverage, lower-frequency control, and greater output.