刘毅2019-02-15 21:45:06
참고하시면 됩니다,
<?php
function test($array=array(),$key='',$paixu=true){
$result=array();
foreach ($array as $k => $v){
$values[$k]= isset($v[$key]) ? $v[$key] : '';
}
unset( $ v);
$paixu ? asort($values) : arsort($values);
foreach ($values $k => $v){
$result[$k] = $array[ $k];
}
return $result;
}
$data = array(
array('post_id'=>1,'title'=>'학습 방법 PHP 잘',' reply_num'=>582),
array('post_id'=>2,'title'=>'PHP 배열의 공통 함수 요약','reply_num'=>182),
array('post_id' =>3,'title'=>'일반적인 PHP 문자열 함수 요약','reply_num'=>982),
);
$paixuhou=test( $data,'reply_num', true);
echo "<pre>";
print_r($paixuhou);
?>