保留索引的 排序

2017-03-13 09:59:51

保留索引的 排序
//esky 保留索引的排序 $test_array = array("first" => 1,"second" => 2,"third" => 3,"fourth" => 4); print_r(shuffle_assoc($test_array));
function shuffle_assoc($input_array){

   foreach($input_array as $key => $value){
     $temp_array[$value][key] = $key;
     }

   shuffle($input_array);

   foreach($input_array as $key => $value){
     $return_array[$temp_array[$value][key]] = $value;
     }

   return $return_array;
   }

发表评论:

Powered by PHP 学习者(mail:517730729@qq.com)

原百度博客:http://hi.baidu.com/ssfnadn

备案号:闽ICP备17000564号-1

开源中国 PHPCHINA