How can I make a function to convert a string to lower-case and replace all spaces with dashes?
Examples:
If the input is "Hello World", the output should be "hello-world".
If the input is "Merhaba Dünya", the output should be "merhaba-dunya".
This is what I have tried so far.
<input name="Title" type="text" class="form-control" placeholder="Title">
<input name="TitleSeo" type="text" class="form-control" placeholder="Title">
function create_seo_url($baslik = "") {
$TR = array('ç', 'Ç', 'ı', 'İ', 'ş', 'Ş', 'ğ', 'Ğ', 'ö', 'Ö', 'ü', 'Ü');
$EN = array('c', 'c', 'i', 'i', 's', 's', 'g', 'g', 'o', 'o', 'u', 'u');
$baslik = str_replace($TR, $EN, $baslik);
$baslik = mb_strtolower($baslik, 'UTF-8');
$baslik = preg_replace('#[^-a-zA-Z0-9_ ]#', '', $baslik);
$baslik = trim($baslik);
$baslik = preg_replace('#[-_ ]+#', '-', $baslik);
return $baslik;
}