I'm attempting to turn Titles to slugs
$string = "آزمون پادشاهی متحده";
$pattern = '/[`~!@#$%^&*()_|+\=?;:..’“\'"<>,€£¥•،٫؟»«\{\}\[\]\\\/]+/gi';
$replacement = '';
$slug = trim(preg_replace($pattern, $replacement, $string));
$slug = str_replace(" ","-",$slug);
The end result should be آزمون-پادشاهی-متحده
spaces replaced by hyphen.
Another example
title: Great Britain
slug: great-britain
How do i solve?