I've actually written a script to do this, but in javascript of all things. It builds the Ulam Square of prime numbers and presents it on a web page. Here it is on my testing site.
http://ronbeau.50webs.com/ulam.html
And there is also a page for a 201 x 201 square.
But there are several things you need to know about generating primes if you want to be efficient. How that page works is by declaring a array and populating it with primes and then using the data from the array to build the page. But building the array involves two steps. You only need to test with primes that are less than the square root of a given number, so you need to build a smaller array containing the numbers to check against.
You can't start your arrays with one, or every number will be considered divisible and none pushed into the array. You have to start your divisor array with two and the big array with three.
It would be very easy to translate that code into PHP but in this case that sort of defeats the purpose, since the page you download is only about 3kb but the page built is over 100kb, making more work for the server while the client machine is sitting there just wating.