Jump to content

seo url with article name


UnknownPlayer

Recommended Posts

Strip any special characters out of the string before using in the url:

 

Try it out:

<?php
function prepare($string) {
$blacklistchars = '#[^-a-zA-Z0-9_ /]#';
$string = preg_replace($blacklistchars, '', $string);
$string = trim($string);
$string = preg_replace('#[-_ ]+#', '-', $string);
$string = strtolower($string);		
return $string;			
}

$title = "This string 'contains' && stuff to remove in the url £ *** $";
$title_for_url = prepare($title);

echo $title_for_url;
exit();
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.