mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 08:58:56 +00:00
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:
parent
4fff12b319
commit
192eda7b75
1 changed files with 4 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue