Skip to content

Instantly share code, notes, and snippets.

@dcangulo
Last active April 14, 2019 07:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcangulo/6c4ef8b928aaa7d4d29cb7875a78f165 to your computer and use it in GitHub Desktop.
Save dcangulo/6c4ef8b928aaa7d4d29cb7875a78f165 to your computer and use it in GitHub Desktop.
A PHP function that converts string to an SEO friendly string. Visit https://www.davidangulo.xyz/ for more information.
<?php
function seoFriendlyUrl($string) {
$string = strtolower($string);
$string = preg_replace('/[^a-z0-9_\s-]/', '', $string);
$string = preg_replace('/[\s_]/', '-', $string);
return $string;
}
//Visit the tutorial for more information
//https://www.davidangulo.xyz/how-to-create-seo-friendly-url-in-php/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment