Skip to content

Instantly share code, notes, and snippets.

@lbvf50mobile
Last active September 19, 2020 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lbvf50mobile/1948022a0a606896c9ef1360a522b70b to your computer and use it in GitHub Desktop.
Save lbvf50mobile/1948022a0a606896c9ef1360a522b70b to your computer and use it in GitHub Desktop.
Just PHP FUN 107.
<?php
# https://www.codewars.com/kata/587731fda577b3d1b0001196 CamelCase Method.
function camel_case(string $s): string {
$tmp = explode(" ",$s);
if(!$tmp) return capitalize($s);
return join("",array_map('capitalize',$tmp));
}
function capitalize($x){ return ucfirst(strtolower($x));}
# Bw2801, _teo_, davgothic, Syrenox, Frankich, roman-1983
function camel_case(string $s): string {
return str_replace(" ","",ucwords($s));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment