Matpatnik Posted January 23, 2008 Share Posted January 23, 2008 <?php$array = Array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", " ", "!", "@", "#", "\\\$", "%", "^", "&", "*", "(", ")", "_", "-", "=", "+", "\\\\", "|", ",", "<", ".", ">", "?", "'", "\\\"", "`", "~");asort($array);echo implode("", $array);?>returns: !"#$%&'()*+,-.0123456789<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\^_`abcdefghijklmnopqrstuvwxyz|~note: the result begins with a spaceI have some problem sorting an array because some entity are the first letter.eg: été will go in front of action which a suppose to be in front of eany idea? Link to comment Share on other sites More sharing options...
boen_robot Posted January 23, 2008 Share Posted January 23, 2008 Try to use natsort(). If that too fails, I'm afraid you're out of luck. The only possible way then would be to construct a special sorting mechanism on your own which will be based on string comparrison. Link to comment Share on other sites More sharing options...
Matpatnik Posted January 23, 2008 Author Share Posted January 23, 2008 Nope, it doesn't work I will have to create my own one. Link to comment Share on other sites More sharing options...
Matpatnik Posted January 23, 2008 Author Share Posted January 23, 2008 I find a way to sort it. I was looking way too far like always lol this is my function: function sort_entity($array) { $total = count($array); for ($i=0;$i<$total;$i++) { if ($array[$i]{0} == '&') { $array[$i] = $array[$i]{1}.$array[$i]; } else { $array[$i] = $array[$i]{0}.$array[$i]; } } sort($array); for ($i=0;$i<$total;$i++) { $array[$i] = substr($array[$i],1); } return $array;} I simply add the second letter at the beginning of the entity, sort it and take it off.if you guys find a better way of doing it, let me know Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.