示例:
'柠檬橙香蕉苹果'--->'elmno aegnor aaabnn aelpp'
'лимонапельсинбананяблоко'--->'илмноаеилнпсьаабннбклооя'
'αβγαβγαβγαβγαβγ'--->'ααββγγαααβββγγγ'
答案 0 :(得分:0)
function array_sorting($ string){
// Split string sequence into array elements
$string = explode(" ", $string);
//print_r($string);
foreach($string as $str) {
// Converting words into array elements
$results = array();
preg_match_all('/./u', $str, $results);
foreach ( $results as $array ) {
// Sorting array elements
sort($array);
// Concat elements back to words
foreach($array as $val){
echo $val;
}
}
// Concat words back to sequence
echo " ";
}
}
array_sorting('αβγαβγαβγαβγαβγ');