1<?php
2$fruits_list = array('Orange', 'Apple', ' Banana', 'Cherry', ' Banana');
3$result = array_unique($fruits_list);
4print_r($result);
5?>
6
7Output:
8
9Array ( [0] => Orange [1] => Apple [2] => Banana [3] => Cherry )
1<?php
2$a=array("a"=>"red","b"=>"green","c"=>"red");
3print_r(array_unique($a));
4?>
5Output : Array ( [a] => red [b] => green )
6
7Example 2:
8
9
10$array = array(1, 2, 2, 3);
11$array = array_unique($array);
12Output : Array is now (1, 2, 3)
13
14