Codility cyclic rotation solution in PHP
You could use array functions. They simplify and speed up the handling of arrays. See: http://php.net/manual/en/ref.array.php

So your code could become:

function rotateArray($inputArray,$rightShiftCount)
// shift all elements of the array to the right a number of times
{
  // extract the part of the array to move to the front
  $partToMove = array_splice($inputArray,-($rightShiftCount % count($inputArray)));
  // return extract part followed by what was left of the array
  return array_merge($partToMove,$inputArray);
}


This function does not check its arguments, if needed you can add that.

Notice that I have used sensible names for my variables instead of $A and $K. This is intentional.