Generate SEF URLs with PHP

When writing a custom website or web application, one of the essential things are SEF URLs. I as most freelance web developers use PHP a lot and I wrote a nice little script that generates SEF URLs with PHP for me, so my pages get a nice boost in Google search engine. Search engine friendly URLs play a major part in the ranking of your website in search engine index (Google, Yahoo, etc.) and they also make the first indication of your blog post or website content.

The SEF URLs with PHP function is as follows:

What this SEF URLs with PHP function does is just a simple regular expresion to remove all non-alphanumeric characters from input and all stop words and implodes the remaining words with a ‘-‘ character. We get a nice SEF URL as out put. For custom made blogs I usually use post title as input for the SEF URLs with PHP function and the following list of stop words:

I usually call this simple script whenever I store new post record to the database and immediatley store the post SEF URL to the database.