I have a site that I'm building out with php that will allow for multi language for content. One part of the site will have business listings. I have SEO friendly urls setup to view these listings, so for example I would have a business listing called "A bar down the street". The url would look like this:
/listing/a-bar-down-the-street
However lets say there is an Arabic version of this listing, then the name would look like this:
شريط أسفل الشارع
How would I make that into the same url format as the English version but in the language it is currently in? When I tried my function on the Arabic version that turns a string into a seo friendly url it comes back empty.
EDIT: To clarify further, all I'm looking for is a php function that allows me to turn any string into an SEO friendly url no matter what language the site is in.
EDIT PART 2 Below is the function Im using to rewrite the string to a SEO friendly url. Perhaps you can tell me what I need to add to make it language friendly?
public function urlTitle($str,$separator = 'dash',$lowercase = TRUE)
{
if ($separator == 'dash')
{
$search = '_';
$replace = '-';
}else
{
$search = '-';
$replace = '_';
}
$trans = array(
'&\#\d+?;' => '',
'&\S+?;' => '',
'\s+' => $replace,
'[^a-z0-9\-_]' => '',
$replace.'+' => $replace,
$replace.'$' => $replace,
'^'.$replace => $replace,
'\.+$' => ''
);
$str = strip_tags($str);
$str = preg_replace("#\/#ui",'-',$str);
foreach ($trans AS $key => $val)
{
$str = preg_replace("#".$key."#ui", $val, $str);
}
if($lowercase === TRUE)
{
$str = mb_strtolower($str);
}
return trim(stripslashes($str));
}