Home >Backend Development >PHP Tutorial >有啥简便的方法解决办法

有啥简便的方法解决办法

WBOY
WBOYOriginal
2016-06-13 10:23:56871browse

有啥简便的方法
//按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>
PHP code
foreach($arr as $v) $t[]=$v['c'];array_multisort($t,$arr);print_r($arr);<div class="clear">
                 
              
              
        
            </div>
Statement:
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