What is the following Python code in PHP?
import sys
li = range(1,777);
def countFigure(li, n):
m = str(n);
return str(li).count(m);
# counting figures
for substr in range(1,10):
print substr, " ", countFigure(li, substr);
Wanted output for 777
1 258
2 258
3 258
4 258
5 258
6 258
7 231
8 147
9 147