Skip to content

Instantly share code, notes, and snippets.

@caseysoftware
Last active December 18, 2015 15:39
Show Gist options
  • Select an option

  • Save caseysoftware/5806193 to your computer and use it in GitHub Desktop.

Select an option

Save caseysoftware/5806193 to your computer and use it in GitHub Desktop.
preg_replace before, using /e
public static function decamelize($word)
{
return preg_replace(
'/(^|[a-z])([A-Z])/e',
'strtolower(strlen("\\1") ? "\\1_\\2" : "\\2")',
$word
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment