If I understand you correctly you wish to check for the current page id being in the array, if it is then you want to increment the value in the array, yes?
If so try this (with a bit of added checking to ensure that the array exists, is an array and contains at least one element)
if(isset($pages) && is_array($pages) && count($pages))
{
while(list($catnum,$howmany) = each ($pages))
{
// is page $id in array
if($id==$catnum)
{
$pages[$id]++; // increment count
break; //jump out of loop
}
}
}
As soon as you increment the array value this way, you probably will have to jump out of the while loop as the internal array pointer used by each may get changed, though it shouldn't, I just don't have a system to test it on at the moment.
This may be what you want to do anyway, as the array indices are unique, so once you have found the page id in the array, there is no point in checking the rest of the array.
If I have got the wrong end of the stick, and I frequently do, I apologise, so could you be a little more specific.