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 215 views
5 answers 428 views
2 answers 305 views
2 answers 187 views
2 answers 240 views
...