| Newsgroups |
php.notes |
| Message-ID |
<[email protected]> |
I didn't see this explicitly mentioned in the documentation but if an array value is not an array (or an object with the correct functions for access) or the column_key doesn't exist then that value will simply not have a corresponding value in the output
so array_column([[4,5,6], [7,8,9], 10], 0) will return [4,7]. It also means that the suggestion of
array_combine(array_keys($array), array_column($array, 'column'));
to preserve keys isn't safe unless you verify that nothing will be excluded by the array_column call.
----
Server IP: 45.112.84.4
Probable Submitter: 45.112.84.18 (proxied: 76.132.2.185)
----
Manual Page -- https://php.net/manual/en/function.array-column.php
Edit -- https://main.php.net/note/edit/130272
Del: integrated -- https://main.php.net/note/delete/130272/integrated
Del: useless -- https://main.php.net/note/delete/130272/useless
Del: bad code -- https://main.php.net/note/delete/130272/bad+code
Del: spam -- https://main.php.net/note/delete/130272/spam
Del: non-english -- https://main.php.net/note/delete/130272/non-english
Del: in docs -- https://main.php.net/note/delete/130272/in+docs
Del: other reasons-- https://main.php.net/note/delete/130272
Reject -- https://main.php.net/note/reject/130272
Search -- https://main.php.net/manage/user-notes.php