◐ Shell
clean mode source ↗

GitHub - aiiro/ArrayBox: ArrayBox, a simple PHP extension for array.

ArrayBox is a PHP helper library that makes easy to manipulate the array.

Require this package with composer using the following command.

After Composer requiring, you need to require Composer's autoload.php.

<?php 
  
require 'vendor/autoload.php';
<?php
  
$data = [
            ['volume' => 67, 'edition' => 2],
            ['volume' => 86, 'edition' => 1],
            ['volume' => 85, 'edition' => 6],
            ['volume' => 98, 'edition' => 1],
            ['volume' => 86, 'edition' => 3],
            ['volume' => 86, 'edition' => 2],
            ['volume' => 67, 'edition' => 7],
        ];
  
$array_box = new \ArrayBox\ArrayBox($data);
$sorted = $array_box->sort2Dimensional('volume', SORT_DESC, 'edition', SORT_ASC);
  
// Result
[
    ['volume' => 98, 'edition' => 1],
    ['volume' => 86, 'edition' => 1],
    ['volume' => 86, 'edition' => 2],
    ['volume' => 86, 'edition' => 3],
    ['volume' => 85, 'edition' => 6],
    ['volume' => 67, 'edition' => 2],
    ['volume' => 67, 'edition' => 7],
];