看板 PHP 關於我們 聯絡資訊
我有一個多維的陣列 像這樣的結構: $arr = array( 0=>array( 'id'=>1, 'name'=> '姓名', 'cfcount'=>1 ), 1=>array( 'id'=>2, 'name'=> '姓名', 'cfcount'=>3 ) ); 我想用usort的方式,讓原本的陣列根據裡面的cfcount 來由大至小排列 usort($arr,fricount); function fricount($a,$b) { if ($a['cfcount'] == $b['cfcount']) return 0; return ($a > $b) ? -1 : 1; } 可是這樣做還是有錯 請問該怎麼做才好 謝謝回答 -- ˊ_▂▃▄▂_ˋ. ◣           ▅▅▅  ▅▅▅  ι●╮     ▍./◤_▂▃▄▂_◥ \'▊    HARUHI ████████  <■┘      ◤◤◥█◥◥█Δ   ISM    ███▃▃███  ¢|\      ζ(▏●‵◥′●)Ψ ▏   By-gamejye ▂▂▂  ▂▂▂   ⊿Δ      /|▋ |\ ▎        ハ ル ヒ 主 義         ◥◥|◣ ‵′ ◢/'◢◢ S‧O‧S 世界をいに盛り上げるための宮ハルヒの団 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.126.209.219
CaptainH:$a > $b <-----an array is greater than another? 11/29 12:17
knives:對喔,寫錯了 11/29 12:55