[ create a new paste ] login | about

Link: http://codepad.org/GisGby3u    [ raw code | output | fork ]

PHP, pasted on Nov 27:
<?php

$array = array(
 'total_ids' => 0,
 'unique_ips' => 0,
 'unique_ids' => 0,
 'global' => 0,
 'total_ips' => 0,
);

function cmp( $a, $b) 
 {
     if( strlen( $a) != strlen( $b))
     {
         return strlen( $a) < strlen( $b) ? 1 : -1;
     }
     return strcasecmp( $a, $b);
 }

var_dump( $array);

uksort( $array, 'cmp');

var_dump( $array);


Output:
array(5) {
  ["total_ids"]=>
  int(0)
  ["unique_ips"]=>
  int(0)
  ["unique_ids"]=>
  int(0)
  ["global"]=>
  int(0)
  ["total_ips"]=>
  int(0)
}
array(5) {
  ["unique_ids"]=>
  int(0)
  ["unique_ips"]=>
  int(0)
  ["total_ids"]=>
  int(0)
  ["total_ips"]=>
  int(0)
  ["global"]=>
  int(0)
}


Create a new paste based on this one


Comments: