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?

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/>";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.