Show alternative usage of array_column() in example

Based on a patch provided by Stefan Topfstedt.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@345315 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Christoph Michael Becker 2018-07-14 12:22:09 +00:00
parent 4fff12b319
commit 192eda7b75

View file

@ -295,6 +295,10 @@ foreach ($data as $key => $row) {
$edition[$key] = $row['edition'];
}
// as of PHP 5.5.0 you can use array_column() instead of the above code
$volume = array_column($data, 'volume');
$edition = array_column($data, 'edition');
// Sort the data with volume descending, edition ascending
// Add $data as the last parameter, to sort by the common key
array_multisort($volume, SORT_DESC, $edition, SORT_ASC, $data);