Saturday, June 11, 2016

remove duplicate from array

<?php
$a=array(1,1,1,2,2,2,3,4,3,5);
$b=array();
$c=0;
for($i=0;$i<count($a);$i++)
{
for($j=0;$j<$c;$j++){
if($a[$i]==$b[$j]){
break;
}
}

if($j==$c){
$b[$c]=$a[$i];
$c++;
}
}
print_r($a);
print_r($b);

?>

No comments:

Post a Comment

Featured Post

What is JavaScript? What is the role of JavaScript engine?

  The JavaScript is a Programming language that is used for converting static web pages to interactive and dynamic web pages. A JavaScript e...