Show unique value form array in php

 <?php

$val = [1,2,2,3,45,45,12];

$val2 = [];


foreach($val as $valfirstInput){

  foreach($val2 as $valsecond){

   if($valfirstInput ==$valsecond){

      continue 2;

   }

   

  }

  $val2[] = $valfirstInput;

}


echo "<pre>";

print_r($val2);


?>

Comments

Popular posts from this blog

Interview question laravel.

My Sql Query ..