PHP: Generate Slug
slug is used to represent URL’s in a friendly way. for example if we have URL
http://www.technoreaders.com/?p=1484
can be converted into
http://www.technoreaders.com/2009/11/04/php-generate-slug/
but for this you need to convert title of your page to to friendly URL. So you can use below function to generate slug of the title of your page.
function generate_slug($url)
{
$slug = strtolower($url);
$slug = preg_replace("/[^a-z0-9\s-]/", "", $slug);
$slug = trim(preg_replace("/\s+/", " ", $slug));
$slug = trim(substr($slug, 0, 45));
$slug = preg_replace("/\s/", "-", $slug);
return $slug;
}
and now to know how use this slug click here
Related Posts
Categories: code, seo convert string to slug, function, Generate Slug, SEO friendly URL, SEO URLs, slug, string to slug, strtolower, URL



is it conversion of dynamic url to static url for google search engine optimization
no, this is just a string to slug converter
Does google read it in the new fashion then? Or the old fashioned way as a regular query string?
Lemme know this, coz I need to kinda implement this on my site too
Also, when it converts it into the new url, can I still access them via $_GET[]?
hey bookworm read this article for the answer
http://www.technoreaders.com/2009/11/27/how-to-use-generated-slug-using-htaccess/