You are not actually increasing your $counter
variable, so it will always stay 0
.
If you want to increase it, use something like:
if ($counter++ >= 3) break;
Although in your specific case you probably need (see the manual):
if (++$counter >= 3) break; // first increment, return value and then compare