Created
June 22, 2017 00:48
-
-
Save sayhicoelho/f0873c4461a018b26aaca79a88f3811d to your computer and use it in GitHub Desktop.
String to snake_case
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 strtosnake($str) | |
{ | |
return ltrim(strtolower(preg_replace('/[A-Z]([A-Z](?![a-z]))*/', '_$0', $str)), '_'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment