0 fka 7 Years Ago My array $pids contains integers. For example: 18742 59274 94255 97124 18742 94255 94255 I wrote: $pid = array_unique($pids); for($i=0; $i<count($pid); $i++) echo $i.' '.$pid[$i].'<br />'; And the output is: 0 18742 1 2 3 What's wrong? Why array_unique() doesn't throw away duplicated values? php
1 smantscheff 265 7 Years Ago array_unique() keeps the indexes intact. If not specified otherwise, these are ascending integers. Try this instead: $pid = array_unique($pids); foreach( $pid as $key => $value ) echo "$key: $value<br/>";