php数组去重

<?php
    $arrStr = array("aa", "bb", "aa", "bb", "ab");

    print("=============orgin arr string=============<br>");
    print_r($arrStr);

    $arr = array_flip(array_flip($arrStr));

    print("<br><br>==============unequie arr==================<br>");
    print_r($arr);
?>
 

 

结果:

=============orgin arr string=============
Array ( [0] => aa [1] => bb [2] => aa [3] => bb [4] => ab )

==============unequie arr==================
Array ( [2] => aa [3] => bb [4] => ab )

你可能感兴趣的:(PHP)