fork(7) download
  1. <?php
  2.  
  3. $arr = array(10,'Foo', 'Abc', 5, 3.2, 'Test','Jonathan');
  4. usort($arr, function($a, $b) {
  5. if (is_int($a) || is_float($a)) {
  6. if (is_int($b) || is_float($b)) {
  7. return $a - $b;
  8. }
  9. else
  10. return -1;
  11. }
  12. elseif (is_int($b) || is_float($b)) {
  13. return 1;
  14. }
  15. else {
  16. return strcmp($a, $b);
  17. }
  18. });
  19. print_r($arr);
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
Array
(
    [0] => 3.2
    [1] => 5
    [2] => 10
    [3] => Abc
    [4] => Foo
    [5] => Jonathan
    [6] => Test
)