Generation

generate functionWed, 21 Dec 2022

Take an array of strings and sort them by the third character of each strings

function sort_string_array($string_array) { usort($string_array, function($a, $b) { if ($a[2] == $b[2]) { return 0; } return ($a[2] < $b[2]) ? -1 : 1; }); return $string_array; }

Questions about programming?Chat with your personal AI assistant