Last active
August 29, 2015 14:22
-
-
Save tanftw/a4284f0d057c4f72182b to your computer and use it in GitHub Desktop.
Snake case in WP
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 | |
/** | |
* Convert a regular string to snake_case | |
* For example, Hello World => hello_world | |
* | |
* @param String $str String to be converted | |
* @return String String in snake_case | |
**/ | |
function str_snake( $str ) | |
{ | |
return str_replace( '-', '_', sanitize_title( $str ) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment