Skip to content

Instantly share code, notes, and snippets.

@Twoody
Created September 5, 2019 17:56
Show Gist options
  • Save Twoody/2e4e53e35e34912862729bc5b3e5d239 to your computer and use it in GitHub Desktop.
Save Twoody/2e4e53e35e34912862729bc5b3e5d239 to your computer and use it in GitHub Desktop.
Code Wars Camel Case Method PHP Problem
<?php
function camel_case(string $s): string {
$items = explode(" ", $s);
$r = "";
for ($i=0; $i<count($items); $i++){
$r .= ucfirst(strtolower($items[$i]));
}//end i-for
return $r;
}
$out1 = camel_case("test case");
echo $out1 . " === \"TestCase\"\n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment