- str_replace: documentation ( source)
- trim: documentation ( source)
- preg_replace: documentation ( source)
<?php
$string = "آزمون پادشاهی متحده";
$pattern = '/[`~!@#$%^&*()_|+=?;:..’“\'"<>,€£¥•،٫؟»«{}[\]\\\\\/]+/ui';
$replacement = '';
$slug = trim(preg_replace($pattern, $replacement, $string));
$slug = str_replace(" ","-",$slug);
echo $slug;