array   (   "Peter"=>50   ),   "Brown"=>array   (   &quo"/> array   (   "Peter"=>50   ),   "Brown"=>array   (   &quo">

怎么对多维数组的键名进行排序

WBOY
Release: 2016-06-13 13:13:50
Original
886 people have browsed it

如何对多维数组的键名进行排序
比如
$families = array
(
  "Griffin"=>array
  (
  "Peter"=>50
  ),
  "Brown"=>array
  (
  "Cleveland"=>30
  )
);
正序排,排完序后的键名和对应的键值不变,形如下面的形式:
$families = array
(
  
  "Brown"=>array
  (
  "Cleveland"=>30
  ),
"Griffin"=>array
  (
  "Peter"=>50
  )
);

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

PHP code
foreach($families as $v) 
      foreach($v as $vl) $p[]=$vl;
      
array_multisort($p,SORT_ASC,$families);      
print_r($families); <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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!