有啥简便的方法解决办法

WBOY
Release: 2016-06-13 13:30:38
Original
783 people have browsed it

有啥简便的方法
//按C的大小重新排列数组
$arr = array(
array('a'=>33,'b'=>32,'c'=>12),
array('a'=>33,'b'=>32,'c'=>13),
array('a'=>33,'b'=>32,'c'=>11)
);



------解决方案--------------------

PHP code
$arr = array(
array('a'=>33,'b'=>32,'c'=>12),
array('a'=>33,'b'=>32,'c'=>13),
array('a'=>33,'b'=>32,'c'=>11)
);
usort($arr, 'sortByC');
function sortByC($a, $b) {
    return $a['c'] - $b['c'];
}
echo '<pre class="brush:php;toolbar:false">';
print_r($arr);
<br><font color="#e78608">------解决方案--------------------</font><br>
Copy after login
PHP code
foreach($arr as $v) $t[]=$v['c'];
array_multisort($t,$arr);
print_r($arr); <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template