Write a PHP function to sort entity letters
<?php function entity_sort($my_array) { $total = count($my_array); for ($i=0;$i<$total;$i++) { if ($my_array[$i]{0} == '&') { $my_array[$i] = $my_array[$i]{1}.$my_array[$i]; } else { $my_array[$i] = $my_array[$i]{0}.$my_array[$i]; } } sort($my_array); for ($i=0;$i<$total;$i++) { $my_array[$i] = substr($my_array[$i],1); } return $my_array; } $arr = array(" ","&", "<"); print_r(entity_sort($arr)); ?>
Sample Output:
Array ( [0] => [1] => < [2] => )
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
Array ( [0] => [1] => < [2] => )need an explanation for this answer? contact us directly to get an explanation for this answer