Make page titles seo-friendly for URL

/ Published in: PHP
Save to your folder(s)

If you have a title, for something like a blog or product, and want to make an seo-friendly name to call it, here is a function.

$title = "This foo's bar is rockin' cool!";
echo make_seo_name($title);

Copy this code and paste it in your HTML
  1. function make_seo_name($title) {
  2. return preg_replace('/[^a-z0-9_-]/i', '', strtolower(str_replace(' ', '-', trim($title))));
  3. }

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.