Last active
August 27, 2019 01:32
-
-
Save crusj/dc5c0bb7f81b22e38357fcbf8d683b17 to your computer and use it in GitHub Desktop.
php变量驼峰转snake
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 | |
trait Camel2Snake | |
{ | |
public function camel2Snake(string $camel): string | |
{ | |
return strtolower(preg_replace('/(?<=[a-z])([A-Z])/', '_$1', $camel)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment