How to delete duplicates in an array?

前端 未结 5 399
南旧
南旧 2020-12-19 07:36

How can I delete duplicates in array?

For example if I had the following array:

$array = array(\'1\',\'1\',\'2\',\'3\');

I want it

5条回答
  •  长情又很酷
    2020-12-19 08:33

    Try this code,

    1){
    
      foreach($key as $key2 => $data2){
        unset($array[$key2]);
          }
        }
       }
       $array=array_values($array);
       print_r($array);
    
    
    ?>
    

    Output

        Array ( [0] => 2 [1] => 3 )
    

提交回复
热议问题