Created
July 2, 2017 14:42
-
-
Save webyroki/e2019aa3fabd90f7585c7bec851bdcb6 to your computer and use it in GitHub Desktop.
solution('abc') // should return ['ab', 'c_'] solution('abcdef') // should return ['ab', 'cd', 'ef']
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//solution('abc') should return ['ab', 'c_'] | |
//solution('abcdef') should return ['ab', 'cd', 'ef'] | |
function solution($str) { | |
$STR = str_split($str, 2); | |
foreach($STR as $key => $value){ | |
$value = str_pad($value, 2, "_", STR_PAD_RIGHT); | |
$STR[$key] = $value; | |
} | |
return $STR; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment