Created
January 24, 2018 08:07
-
-
Save telingadigital/c2e53c1c6c2315c67dbf64a8afd8c821 to your computer and use it in GitHub Desktop.
Convert CamelCase to Snake-Case
This file contains hidden or 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 convert($string) { | |
return strtolower(preg_replace(['/([a-z\d])([A-Z])/', '/([^_])([A-Z][a-z])/'], '$1_$2', $string)); | |
} | |
echo convert('AnyStringAvailable'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment