Last active
November 16, 2016 03:07
-
-
Save tohokuaiki/3138a9a2450c00077da2e3d60bd03e4d to your computer and use it in GitHub Desktop.
命名則のまんま。多分suinさんところのblogからもらった。
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 | |
function pascalize($string){ | |
$string = strtolower($string); | |
$string = str_replace('_', ' ', $string); | |
$string = ucwords($string); | |
$string = str_replace(' ', '', $string); | |
return $string; | |
} | |
function camelize($string){ | |
$string = self::pascalize($string); | |
$string[0] = strtolower($string[0]); | |
return $string; | |
} | |
function snake_case($string){ | |
$string = preg_replace('/([A-Z])/', '_$1', $string); | |
$string = strtolower($string); | |
return ltrim($string, '_'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment