<?php $names = array( 'John Doe', 'Tom Watkins', 'Jeremy Lee Jone', 'Chris Adrian',); usort($names, function($a, $b) { $a = substr(strrchr($a, ' '), 1); $b = substr(strrchr($b, ' '), 1); return strcmp($a, $b);}); var_dump($names);
Standard input is empty
array(4) { [0]=> string(12) "Chris Adrian" [1]=> string(8) "John Doe" [2]=> string(15) "Jeremy Lee Jone" [3]=> string(11) "Tom Watkins" }
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!