I'm assuming that $counter would be an integer variable, instead of an array. array_push() takes an array for the first parameter, and the additional values to add to that array.
In your case, it looks like you're wanting to set the array's key for count to the variable $counter, which you can do like so:
$json = array(
'ack' => 'success',
'totalPages' => $total_pages,
'currentPage' => $pageno,
'results' => array(),
'count' => 0,
);
$json['count'] = $counter;
Edit:
Additionally, if you're setting the variable above for your response, and you're not doing any further code changes, you can just declare your $json array with the $counter variable, similar to how you have for totalPages and currentPage, and for completeness:
$json = array(
'ack' => 'success',
'totalPages' => $total_pages,
'currentPage' => $pageno,
'results' => array(),
'count' => $counter, // Set the $counter variable here, straight away!
);
$json['count'] = $counter; echo $json['count'];?$counterset to a value? If it is not, it will benull