I get the elements from MySql as array with the data as given:\[code\]$month = (Array ( [0] => 5 [1] => 6 [2] => 5 ) Array ( [0] => 5 ) Array ( [0] => 5 [1] => 1 [2] => 1 [3] => 1 [4] => 5 [5] => 5 [6] => 5 ) )\[/code\]From this array I manupulate:\[code\]$mon = Array ( [0] => 5 [1] => 6 ) $temp = Array ( [5] => 2 [6] => 1 ) \[/code\]I take the "mon" element and matching with key of "temp" array and just output the element. Here's my code:\[code\] while($fetch=mysql_fetch_array($query)) { $month = explode(',',$fetch['Months']); /*one of the fields from DB */ $mon = array_unique(explode(',',$fetch['Months'])); sort($month1); $temp =array_count_values($month); ksort($temp); for($i=0; $i<max($mon ); $i++) { if(array_key_exists($mon [$i], $temp)) echo $temp[$i]; } }\[/code\]I don't get the correct out put. "echo $temp[$i]" is not getting the element.