$str = "WordWordWordWord";
$str_new = preg_replace("/([A-Z])/", "_\\1", $str);
$formatStr = strtolower(substr($str_new,1));
var_dump($str);
echo "<br/>";
print_r($formatStr);
echo "<br/>";
echo "<br/>";
$str="AbcDefGhi";
$array=preg_split("/(?=[A-Z])/",$str);
$b= strtolower(substr(implode("_", $array),1));
print_r($array);
echo "<br/>";
print_r($b);
image.png
网友评论