It's not that hard. You need to learn how to make socket connections to a website, and post data to them. The website will reply and send you back the relevant information.
Here's how:
Make a socket connection to http://www.dnsstuff.com or other lookup site.
If you look at dnsstuff.com there is a form on there that lets you do lookups. View the source on that page. Note down the URL the form submits to, and the names off all the variables in the form.
In php using the socket connection you created, send a post header (using fput()) with relevant data you jotted down from the form, to the URL the form submits to. Basically you are doing here what your webbrowser does here when you fill in a form.
Use fget() to retrive the data the server sends back in response. You will then need to use a regular expression to extract what you need from the data. The server will just send back HTML so you will need to use a regular expression to get what you want. It shouldn't be too tricky.
And that's about it. I'll leave it up to you to go about implementing it. Have a go. If you get really stuck I'll post some code to get you started.
Just read php documentation on the following functions and you should be right:
fsockopen()
fput()
fget()
those three function will allow you to comunicate with another website from php.
Good luck
-Adam 🙂