Array sorting problem! $ A = array ('Zhang San' => 'Zookeeper pick up the parameter ', 'Lily' => 'one click and pick up the parameter', 'Wang Wu' => 'Zookeeper ', 'Sun 6' => 'Sun 6', 'Chen 7' => 'wan wowang Yi Erqing ');
Sort the array by the numeric size represented by the man without changing the index. the output result should be in the following format:
Array ', 'Sun 6' => 'Sun 6', 'Chen 7' => 'wan wowang Yi Erqing ');
The code should be as simple as possible. I am a newbie and use the array sorting function for final sorting.
Reply to discussion (solution)
$ A = array ('Zhang San' => 'Zookeeper pick up the parameter ', 'Lily' => 'one click and pick up the parameter', 'Wang Wu' => 'Zookeeper ', 'Sun 6' => 'Sun 6', 'Chen 7' => 'Lou WOWO '); $ t = array_map ('cton ', $ a); array_multisort ($ t, $ a); print_r ($ a); function cton ($ s) {$ dw = array ('pick' => 10, 'hangzhou' => 100, 'hangzhou' => 1000, 'wan' => 10000); $ digital = array ('0' => 0, 'yi' => 1, 'ER' => 2, 'san' => 3, 'Si '=> 4, 'Wu' => 5, 'loan' => 6, 'login' => 7, 'login' => 8, 'login' => 9); $ ar = preg_split ('/('. join ('|', array_keys ($ dw )). ')/', $ s,-0, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); for ($ I = 0; $ I
Array ([Li Si] => Yi Yu pick up [Zhang San] => Si Yu pick up 3 [Wang Wu] => Xiao Yu [Sun 6] => Yi Han Lu pick up [Chen Qi] => Si Wan Wu Yi Eryi)
$ Ar = preg_split ('/('. join ('|', array_keys ($ dw )).')/',
$ S,-0, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE );
Can you comment on this section? Thank you.
'/('. Join ('|', array_keys ($ dw )).')/'
Construct a regular rule string such as/(pick up | unlock | fail | )/
As for how to use the preg_split function, the manual has made it clear.