php) usort : array 정렬을 사용자기준에 맞게 하는 방법
경비항목을 arr를 중요도 순서(사용자기준)대로 정렬하고 싶을때, usort를 사용한다. $arr = array( array( name=>'감가상각비', value=> 88000), array( name=>'협회비', value=>66000), array( name=>'기공료', value=>6500), array( name=>'수선비', value=>9000 ) ); usort($arr, function($a, $b){ $sort = array('협회비'=>0, '기공료'=>1,'감가상각비'=>2,'수선비'=>3); //중요도 순서대로 index를 지정한다. return ($sort[$a['name']]>$sort[$b['name']])?1:-1; }); echo $arr; //정렬된 결과 [ { "n..
2021.06.10