Reason for $uniques
output is
Array
(
[0] => 1
[1] => 5
[2] => 2
[3] => 6
[4] => 3
[6] => 7
)
Your array doesn't contain key 5
, but in your for
loop echo $uniques[$i];
not hold the value of echo $uniques[5];
. that is the reason value 7
is missing.
Try this,
foreach($uniques as $unique){
echo $unique;
}
instead of
for($i = 0; $i < count($uniques); $i++)
OR, you can re-index the array using array_values($uniques)
and use,
$uniques = array_values($uniques);
for($i = 0; $i < count($uniques); $i++)
echo $uniques[$i];