How to remove the duplicate elements from an array in PHP

1 Answer

0 votes
$arr = array(3, 5, 9, 1, 7, 8, 1, 9, 0, 3, 9);   
 
$arr = array_unique($arr);
 
foreach($arr as $n) {
    echo $n . "\n";
}
 
 
 
 
/*
run:
 
3
5
9
1
7
8
0
 
*/

 



answered May 4, 2020 by avibootz

Related questions

2 answers 230 views
5 answers 455 views
2 answers 323 views
2 answers 196 views
2 answers 256 views
...