Return to Snippet

Revision: 7817
at August 14, 2008 00:01 by jdstraughan


Initial Code
function make_seo_name($title) {
	return preg_replace('/[^a-z0-9_-]/i', '', strtolower(str_replace(' ', '-', trim($title))));
}

Initial URL

                                

Initial Description
If you have a title, for something like a blog or product, and want to make an seo-friendly name to call it, here is a function.

SAMPLE INPUT:
$title = "This foo's bar is rockin' cool!";
echo make_seo_name($title);
//RETURNS:
//this-foos-bar-is-rockin-cool

Initial Title
Make page titles seo-friendly for URL

Initial Tags
regex, php

Initial Language
PHP