fork(17) download
  1. <?php
  2.  
  3. $names = array(
  4. 'John Doe',
  5. 'Tom Watkins',
  6. 'Jeremy Lee Jone',
  7. 'Chris Adrian',
  8. );
  9.  
  10. usort($names, function($a, $b) {
  11. $a = substr(strrchr($a, ' '), 1);
  12. $b = substr(strrchr($b, ' '), 1);
  13. return strcmp($a, $b);
  14. });
  15.  
  16. var_dump($names);
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
array(4) {
  [0]=>
  string(12) "Chris Adrian"
  [1]=>
  string(8) "John Doe"
  [2]=>
  string(15) "Jeremy Lee Jone"
  [3]=>
  string(11) "Tom Watkins"
}