Skip to content

Instantly share code, notes, and snippets.

@WGrape
Created February 17, 2022 05:16
Show Gist options
  • Save WGrape/0f925647b958342b1f0d5874a3b9b57d to your computer and use it in GitHub Desktop.
Save WGrape/0f925647b958342b1f0d5874a3b9b57d to your computer and use it in GitHub Desktop.
下划线转驼峰
<?php
function snakeToCamelCase($string){
$result = '';
$subIndexArr = explode('_', $string);
foreach ($subIndexArr as $index => $temp) {
if ($index === 0) {
$result .= $temp;
} else {
$result .= ucfirst($temp);
}
}
return $result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment