Suppose $inputArray is our array which have some repeated elements.
Output :
Array
(
[0] => 1
[1] => 4
[2] => 2
[3] => 6
[4] => 9
[5] => 7
)
You like this post don't forgot to leave a comment.
Chears :)
Happy coding..
$inputArray = array(1, 4, 2, 1, 6, 4, 9, 7, 2, 9);
$outputArray = array();
foreach($inputArray as $inputArrayItem){
foreach($outputArray as $outputArrayItem) {
if($inputArrayItem == $outputArrayItem) {
continue 2;
}
}
$outputArray[] = $inputArrayItem;
}
echo "<pre>";
print_r($outputArray);
Output :
Array
(
[0] => 1
[1] => 4
[2] => 2
[3] => 6
[4] => 9
[5] => 7
)
You like this post don't forgot to leave a comment.
Chears :)
Happy coding..