<?php//lower Upper next UpperfunctionlUnUS($str)
{
$t = explode("_", $str);
$res = "";
for ($i = 0; $i < count($t); $i++) {
$res = $res . ucfirst($t[$i] . "");
}
returnrtrim($res, "");
}
//lower Upper next UpperfunctionlUnU($str)
{
$t = explode("_", $str);
$res = "";
for ($i = 0; $i < count($t); $i++) {
$res = $res . ucfirst($t[$i]);
}
return$res;
}
//lower Lower next UpperfunctionlLnU($str)
{
$t = explode("_", $str);
$res = "";
for ($i = 0; $i < count($t); $i++) {
if ($i == 0) {
$res = $res . lcfirst($t[$i]);
} else {
$res = $res . ucfirst($t[$i]);
}
}
return$res;
}
//upper Upper next UnderlinefunctionuUnU($str)
{
$str = preg_replace('/(?<!^)([A-Z])/', '_\\1', $str);
$t = explode("_", $str);
$res = "";
for ($i = 0; $i < count($t); $i++) {
$res = $res . lcfirst($t[$i]) . "_";
}
returnrtrim($res, "_");
}$str = "data_baru";
echo"<br>";
echolUnUS($str); //data_baru TO Data Baruecho"<br>";
echolUnU($str); //data_baru TO DataBaruecho"<br>";
echolLnU($str); //data_baru TO dataBaru$str = "DataBaru";
echo"<br>";
echouUnU($str); //DataBaru TO data_baru
Copyright 2022 M. Fadli Zein