I have a website that I create using php, which will allow you to use several languages for content. One part of the site will have listings of companies. I have SEO friendly URL settings for viewing these lists, so for example, I will have a business listing called "Bar down the street." The url will look like this:
/listing/a-bar-down-the-street
However, let's say there is an Arabic version of this list, then the name will look like this:
شريط أسفل الشارع
How can I do this in the same URL as the English version, but in the language it is currently in? When I tried my function in the Arabic version, which turns the string into a friendly URL, it returns empty.
EDIT:
To clarify, 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 this site is in.
EDIT PART 2
The following is an Im function that uses to rewrite a string into an SEO friendly URL. Perhaps you can tell me what I need to add in order to make it a language?
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));
}