Find Non Repetable element from an array using php
Please check the below php script to display non repetable element in an array.this script will remove all repetable elements and display remaining elements.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
<?php $first_array=array(1,2,3,4,1,2,3,4,5,9,10,3,67); $count=count($first_array); for($i=0;$i<$count;$i++){ $check_exist = false; for($j=0;$j<$count;$j++){ if($i!=$j) { $result_array[$i]=$first_array[$i]; if($first_array[$i] == $first_array[$j]){ $result_array[$i]='';break; } } } echo "<br>"; } foreach($result_array as $val) { echo $val;echo "<br>"; } ?> |