Skip to content

Latest commit

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

string_php

  • Function
<?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, "_");
}
  • Result
$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

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages