Voting

: eight plus zero?
(Example: nine)

The Note You're Voting On

Hayley Watson
11 months ago
If an entry in the source array does not have a column_key element then array_column will silently skip that entry and return an array shorter than the source.

If entries can't be uniquely identified by an index_key then there's no way of telling which ones were skipped, as without an index_key array_column returns a plain list.

<?php
$array
= [
[
'a' => '0th', 'b' => 'zero'],
[
'a' => '1st', 'b' => 'one'],
[
'a' => '2nd' /* oops */],
[
'a' => '3rd', 'b'=>'three']];
var_export(array_column($array, 'b'));
var_export(array_column($array, 'b', 'a'));
?>

<< Back to user notes page

To Top