SEO friendly Slug is very important in Search Engine Optimization. It is used to rewrite your URL as your title.
as if you write title: "My Name Is Sami" And if it is a page. Then
Its URL will be :
www.QWC.me/?page=1 [1 Is Page ID]
If you use title in URL it can be like it
www.QWC.me/?page=my20%name20%is20%sami
But if you use slug function: URL will be SEO friendly like
www.QWC.me/?page=my-name-is-sami
There are many function: I am going to add 2 good functions for it. there is no any personal PHP built in function.
1:
2:
as if you write title: "My Name Is Sami" And if it is a page. Then
Its URL will be :
www.QWC.me/?page=1 [1 Is Page ID]
If you use title in URL it can be like it
www.QWC.me/?page=my20%name20%is20%sami
But if you use slug function: URL will be SEO friendly like
www.QWC.me/?page=my-name-is-sami
There are many function: I am going to add 2 good functions for it. there is no any personal PHP built in function.
1:
function slug($str, $replace=array(), $delimiter='-')
{
if( !empty($replace) )
{
$str = str_replace((array)$replace, ' ', $str);
}
$clean = iconv('UTF-8', 'ASCII//TRANSLIT', $str);
$clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $clean);
$clean = strtolower(trim($clean, '-'));
$clean = preg_replace("/[\/_|+ -]+/", $delimiter, $clean);
$clean = form_validation($clean);
return $clean;
}
2:
function slug2($string){
$slug=preg_replace('/[^A-Za-z0-9-]+/', '-', $string);
return $slug;
}




