Send A Message

If you have a question or comment, drop me a line and I'll be
sure to get back to you. I'm always available to answer any
questions you have regarding your website.

Full Name

Email Address

What can I help you with?


strtoslug() – SEO Friendly URL’s with PHP

October 8, 2009 at 4:52 pm | PHP | No comment

Quick n’ Simple.  Check it:

function strtoslug($str) {
	$str = strtolower(trim($str));
	$str = preg_replace('/[^a-z0-9-]/', '-', $str);
	$str = preg_replace('/-+/', "-", $str);
	return $str;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Spam protection by WP Captcha-Free