php创建波斯语/阿拉伯语搜索引擎友好的URL(unicode)

I try to make search engine firendly urls are included Persian or Arabic characters .
In url SPACES and symbols must replace with - character.

My Example input is : عنوان آزمایشی - Test Title

I try to do it with my Function :

$title = trim(ereg_replace(' +', ' ', preg_replace("/[^اآبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهیa-zA-Z0-9\s]/", '', strtolower($title))));

But give a result : عنوان-آزما�ش�-test-title

Result must be : عنوان-آزمایشی---Test-Title (for example)

Where's the problem ? I know Persian words are on Unicode but don't know how to pass it !

EDIT : problem like character ی or یـ always turn into , but I try to find a safer way.

I don't find a solution on Internet but find the solution myself on simplest way :

preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&$1', $title);

Result is pretty good .

The problem was that strtolower is not multibyte-capable.

Instead, consider mb_strtolower which handles multi-byte UTF characters.