function cmp($a, $b)
{
    if($a["c"]>$b["c"]){
      return 1;
    }else {
     if($a["c"]==$b["c"]){
      return 0;
     }else{
      return -1;
     }
    }
}usort($custInfoArr, "cmp");

解决方案 »

  1.   

    while ($row = pg_fetch_assoc($rsID)) {
    /*不明白你为什么要这么导数据*/
    $temp["a"] = $row["a"];
    array_push($custInfoArr, $temp["a"]);
    $temp["b"] = $row["b"];
    array_push($custInfoArr, $temp["b"]);
    $temp["c"] = $row["c"];
    array_push($custInfoArr, $temp["c"]);
    $temp["d"] = $row["d"];
    array_push($custInfoArr, $temp["d"]);//这样你得到的就是一个一维数组//再排序
    }
      

  2.   

    1、建议将
    while ($row = pg_fetch_assoc($rsID)) {
      $temp["a"] = $row["a"];
      $temp["b"] = $row["b"];
      $temp["c"] = $row["c"];
      $temp["d"] = $row["d"];
    array_push($custInfoArr, $temp);
    }
    修改为
    while ($row = pg_fetch_assoc($rsID)) {
      $custInfoArr[] = $row;
    }
    代码变少,结果一样2、多维数组的排序需要先获取一维的排序关键字数组,然后通过array_multisort函数排序
    $custInfoArr = array(
      "0" => array("a"=>a,"b"=>b,"c"=>c,"d"=>d),
      "1" => array"a"=>a,"b"=>b,"c"=>c,"d"=>d),
      "2" => array"a"=>a,"b"=>b,"c"=>c,"d"=>d),
    );
    foreach($custInfoArr as $v)
      $t[] = $v['c'];array_multisort($t, SORT_DESC, $custInfoArr);3、结合你的应用,读取关键字数组可在读取记录时进行
    while ($row = pg_fetch_assoc($rsID)) {
      $custInfoArr[] = $row;
      $t[] = $row['c'];
    }
    array_multisort($t, SORT_DESC, $custInfoArr);