Created
March 3, 2022 13:33
-
-
Save Traineratwot/1406decab7b3d7bb8a304660fa320336 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 | |
function name2class($name) | |
{ | |
$name = preg_replace("@([A-Z])@","_$1",$name); | |
$name = strtr($name, [ | |
'\\' => '_', | |
'/' => '_', | |
'-' => '_', | |
' ' => '_', | |
'*' => '_', | |
'.' => '_', | |
'+' => '_', | |
]); | |
$n = explode("_", $name); | |
$n2 = []; | |
foreach ($n as $value) { | |
$n2[] = ucfirst(mb_strtolower($value)); | |
} | |
$class = ucfirst(implode('', $n2)); | |
return $class; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment