Created
November 21, 2019 03:01
-
-
Save byjg/d69d1ad7fdbf254d7ef2f6b6f929f63e to your computer and use it in GitHub Desktop.
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 | |
echo toKebabStyle("TestingConversion"); | |
function toKebabStyle($input) { | |
$result = preg_replace_callback( | |
'/([a-z])([A-Z])/', | |
function ($match) use ($input) { | |
return $match[1] . "-" . $match[2]; | |
}, | |
$input | |
); | |
return strtolower($result); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment