0

I am trying to create our blog title as URL

For example : Blog title is "How to replace character?" So in URL using it as "how-to-replace-character"

All things are working fine but sometime URL format is not in good format.

For example : Title : "How to change & use title for blog" After replace space and special character its "how-to-change---use-title-for-blog"

Using code to replace special characters and spaces

$trimtitle = trim($row["title"]);
$temppurl = preg_replace("/[^a-zA-Z]+?/", "-",strtolower($trimtitle));
$purl = rtrim($temppurl,"-");
$purl1 = ltrim($temppurl,"-");
echo $purl1;

What i am looking for is only single "-" between two words or characters like "how-to-change-use-title-for-blog"

If i want to remove some stop words from URL format like "is,am,are etc" then please suggest me that how can i do it in PHP.

John Conde
  • 217,595
  • 99
  • 455
  • 496

0 Answers0