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

两个数组怎么排序一样

WBOY
WBOYOriginal
2016-06-13 10:41:551126browse

两个数组如何排序一样?
比如:$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>
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