Skip to content

Instantly share code, notes, and snippets.

@byjg
Created November 21, 2019 03:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save byjg/d69d1ad7fdbf254d7ef2f6b6f929f63e to your computer and use it in GitHub Desktop.
Save byjg/d69d1ad7fdbf254d7ef2f6b6f929f63e to your computer and use it in GitHub Desktop.
<?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