Created
September 1, 2022 15:32
-
-
Save guimadaleno/bc55605cda5c76f0e059747d87645eb6 to your computer and use it in GitHub Desktop.
Create slug from string
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 | |
/** | |
* Replaces spaces between string by hyphens | |
* @param string $str | |
* @return string | |
*/ | |
function create_slug ($str) | |
{ | |
return strtolower(preg_replace('/[^A-Za-z0-9-]+/', '-', $str)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment