Skip to content

Instantly share code, notes, and snippets.

@lbvf50mobile
Created August 20, 2020 16:01
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/6005a8ea73fa45f4bc89a83c809a3dc2 to your computer and use it in GitHub Desktop.
Save lbvf50mobile/6005a8ea73fa45f4bc89a83c809a3dc2 to your computer and use it in GitHub Desktop.
Just PHP FUN 081.
<?php
# https://www.codewars.com/kata/515de9ae9dcfc28eb6000001 Split Strings.
function solution($str) {
$size = strlen($str); $ans = [];
if(1 == $size%2) $str .= "_";
for($i = 0; $i < $size; $i += 2) array_push($ans,substr($str,$i,2));
return $ans;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment