Home > Backend Development > PHP Tutorial > 两个数组怎么排序一样

两个数组怎么排序一样

WBOY
Release: 2016-06-13 10:41:55
Original
1130 people have browsed it

两个数组如何排序一样?
比如:$a=[1,2,3]; $b=[3,2,1];

问题:
如何把$b弄的和$a一样

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

PHP code
$a = array(1,2,3);$b = array(3,2,1);foreach($a as $v) $r[] = array_search($v, $b);array_multisort($r, $b);print_r($b);<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