Login +

Documentation

SLS_String::arrayMultiSort

Since SillySmart 1.0

Description

Equivalent to native php function array_multisort() but recursive on the columns
static array arrayMultiSort ( array $data, array $keys);

Parameters

  • array $data
    the array to sort
  • array $keys
    arobrescence of the sort

Return

array $result
the array sorted

Exemples

  •  $test = array(
     0 => array(
     "day" => "04",
     "month" => "05",
     "year" => "2007"),
     1 => array(
     "day" => "03",
     "month" => "03",
     "year" => "2007"),
     2 => array(
     "day" => "07",
     "month" => "04",
     "year" => "2007")
     );
     print_r(SLS_String::arrayMultiSort($test,array(
     array(
     'key' => 'year',
     'sort'=>'desc'),
     array(
     'key' =>'month',
     'sort'=>'desc'),
     array(
     'key' =>'day',
     'sort'=>'desc')
     )));
     // will produce :
     array(0 => array(
     "day" => "04",
     "month" => "05",
     "year" => "2007"),
     1 => array(
     "day" => "07",
    "month"=> "04",
     "year" => "2007"),
     2 => array(
     "day"=> "03",
     "month"=> "03",
     "year"=> "2007")
     );

Comments

No comment on this function, be the first !

Add your comment

You must login/register to post a reply.