Example #1
0
 public function testMultisortWithColumn()
 {
     $input = [["id" => "42", "name" => "Jakob", "age" => 37], ["id" => "43", "name" => "Topher", "age" => 18], ["id" => "43", "name" => "Allan"]];
     $this->assertEquals([37, 18], array_column($input, "age"));
     $this->assertEquals([37, 18, null], arr_column($input, "age"));
     $this->assertEquals([["id" => "43", "name" => "Allan"], ["id" => "43", "name" => "Topher", "age" => 18], ["id" => "42", "name" => "Jakob", "age" => 37]], arr_multisort(arr_column($input, "age"), $input)[1]);
 }
Example #2
0
 public function testColumn()
 {
     $input = [["id" => "42", "name" => "Jakob", "age" => 37], ["id" => "43", "name" => "Topher", "age" => 18]];
     // $this->assertEquals([ "Jakob", "Topher" ], arr_column($input, "name"));
     $this->assertEquals([42 => "Jakob", 43 => "Topher"], arr_column($input, "name", "id"));
 }