note 129521 added to function.array-column

From: Date: Thu, 23 May 2024 11:02:12 +0000
Subject: note 129521 added to function.array-column
Groups: php.notes 
Request: Send a blank email to php-notes+get-221338@lists.php.net to get a copy of this message
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')); ?> ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.137 (proxied: 222.152.65.7) ---- Manual Page -- https://php.net/manual/en/function.array-column.php Edit -- https://main.php.net/note/edit/129521 Del: integrated -- https://main.php.net/note/delete/129521/integrated Del: useless -- https://main.php.net/note/delete/129521/useless Del: bad code -- https://main.php.net/note/delete/129521/bad+code Del: spam -- https://main.php.net/note/delete/129521/spam Del: non-english -- https://main.php.net/note/delete/129521/non-english Del: in docs -- https://main.php.net/note/delete/129521/in+docs Del: other reasons-- https://main.php.net/note/delete/129521 Reject -- https://main.php.net/note/reject/129521 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221338) next »