Last active
April 14, 2019 07:08
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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