Skip to content

Instantly share code, notes, and snippets.

@zawmyohtet
Created December 31, 2015 10:36
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 zawmyohtet/1bed2749b6d03410f302 to your computer and use it in GitHub Desktop.
Save zawmyohtet/1bed2749b6d03410f302 to your computer and use it in GitHub Desktop.
My CodeFight HappyNewYear Challenge solution
<?php
function happyNewYear($wish){
$st = explode(" ", addslashes($wish));
$mx = max(array_map("strlen", $st));
$re[] = str_repeat("*", $mx + 4);
for ($i = 0; $i < sizeof($st); $i++ ){
$re[] = "* " . $st[$i] . str_repeat(" ", ($mx - strlen($st[$i]))) . " *" ;
}
$re[] = $re[0];
return $re;
}
print_r(happyNewYear("Happy's New Year and CodeFight On in 2016!"));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment