| 
	
 | 
 Posted by Janwillem Borleffs on 12/18/05 03:10 
Stefan Mueller wrote: 
> Is it somehow possible to tell sort that it has to handle 'A' like 
> 'a' and also 'δ' like 'a'? 
> 
 
Not with sort; have a go with array_multisort instead: 
 
// Translates 'δ' to 'a', 'λ' to 'e' etcetera 
function translate($str) { 
     $table = get_html_translation_table(HTML_ENTITIES); 
     $pattern = '/^&(.)(tilde|grave|acute|circ|tilde|uml);$/'; 
     $ret = ''; 
 
     for ($i = 0, $max = strlen($str); $i < $max; $i++) { 
          if (preg_match($pattern, @$table[$str{$i}], $m)) { 
               $ret .= $m[1]; 
          } else { 
               $ret .= $str{$i}; 
          } 
     } 
     return $ret; 
} 
 
$values = array(); 
foreach ($my_array as $e) { 
 $values[] = translate(strtolower($e[0])) . $e[1]; 
} 
array_multisort($values, SORT_ASC, $my_array); 
 
 
JW
 
  
Navigation:
[Reply to this message] 
 |