note 117292 added to function.array-column
| From: | marianbucur17 at yahoo dot com | Date: | Mon, 18 May 2015 06:19:18 +0000 |
| Subject: | note 117292 added to function.array-column | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-202582@lists.php.net to get a copy of this message | ||
If array_column is not available you can use the following function, which also has the $index_key
parameter:
if (!function_exists('array_column')) {
function array_column($array, $column_key, $index_key = null)
{
return array_reduce($array, function ($result, $item) use ($column_key, $index_key)
{
if (null === $index_key) {
$result[] = $item[$column_key];
} else {
$result[$item[$index_key]] = $item[$column_key];
}
return $result;
}, []);
}
}
----
Server IP: 72.52.91.14
Probable Submitter: 5.2.230.230
----
Manual Page -- http://php.net/manual/en/function.array-column.php
Edit -- https://master.php.net/note/edit/117292
Del: integrated -- https://master.php.net/note/delete/117292/integrated
Del: useless -- https://master.php.net/note/delete/117292/useless
Del: bad code -- https://master.php.net/note/delete/117292/bad+code
Del: spam -- https://master.php.net/note/delete/117292/spam
Del: non-english -- https://master.php.net/note/delete/117292/non-english
Del: in docs -- https://master.php.net/note/delete/117292/in+docs
Del: other reasons-- https://master.php.net/note/delete/117292
Reject -- https://master.php.net/note/reject/117292
Search -- https://master.php.net/manage/user-notes.php