You can use the slug() function to create SEO-friendly tags. The slug() function will replace space with minus - sign.
For example -
SEO friendly Slug
Output -
seo-friendly-slug
Kindly use the slug() function while inserting all tags.
How to add minus - sign between tag words?
We use explode function and create an array of all tags. Use a comma delimiter to make string to array -
for example -
Tags - seo friendly,php programming, my slug
First of all , convert this string to an array.
Use foreach loop and slug function.
Implode array to string.
<?php
function slug($text){
$text = preg_replace('~[^\\pL\d]+~u', '-', $text);
$text = trim($text, '-');
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
$text = strtolower($text);
$text = preg_replace('~[^-\w]+~', '', $text);
if (empty($text))
{
return 'n-a';
}
return $text;
}
$tags="seo friendly,php programming,my slug";
$tagarray=explode(",",$tags);
$newarr=array();
foreach($tagarray as $tag)
{
$tag=slug($tag);
$newarr[]=$tag;
}
echo $seo_friendly=implode(",", $newarr);
?>
Output-
seo-friendly,php-programming,my-slug