Two-dimensional arrays are sorted by one of the key values :? Phpfunctionmultisort (} Getargsnumber. $ arg_countfunc_num_args (); arrays. for ($ i1; $ I $ arg_count; $ I ++) {$ argfunc_get_arg ($ I); if (! Preg_match (
Two-dimensional arrays are sorted by one of the key values :? Php function multisort (} // Get args number. $ arg_count = func_num_args (); // Get keys to sort by and put them to SortRule array. for ($ I = 1; $ I $ arg_count; $ I ++) {$ arg = func_get_arg ($ I); if (! Preg_match (
Two-dimensional arrays are sorted by one of the key values:
$ Info) {foreach ($ key_name_list as $ key_name) {$ {$ key_name} [$ key] = $ info [$ key_name] ;}} // Create the eval string and eval it. $ eval_str = 'array _ multisort ('. implode (',', $ sort_rule ). ', $ array);'; eval ($ eval_str); return $ array ;} $ data = Array (0 => Array ('title' => 'u8-HR Ningxia ', 'linkline' => 'space. php? Uid = 4018 & do = album & id = 498 ', 'time' => 1275012236, 'content' => 'u8-HR Ningxia ', 'from' => 'alipay'), 1 => Array ('title' => 'u8 AII-in-One national tour-Jining station ', 'linkline' => 'space. php? Uid = 2770 & do = album & id = 339 ', 'time' => 1268628887, 'content' => 'u8 AII-in-One national tour-Jining station ', 'from' => 'alipay'), 2 => Array ('title' => 'u8 ALL-IN-ONE tour-Henan station ', 'linkline' => 'space. php? Uid = 1282 & do = album & id = 359 ', 'time' => 1269333609, 'content' => 'u8 ALL-IN-ONE tour-Henan station ', 'from' => 'alipay'), 3 => Array ('title' => 'First click to U8 All-in-One experience disc', 'linkline' => 'space. php? Uid = 3857 & do = album & id = 665 ', 'time' => 1285049939, 'content' => 'upload to U8 All-in-One experience disks ', 'from' => 'alipay'); print_r (multisort ($ data, 'time', 'sort _ desc');?>
In this way, the $ data array is reordered by its own time key.
Original article address: Two-dimensional arrays are sorted by one of the key values. Thank you for sharing it with the original author.