[ create a new paste ] login | about

Link: http://codepad.org/PJ3LWKb0    [ raw code | output | fork | 2 comments ]

PHP, pasted on Aug 4:
1
2
3
4
5
6
7
8
9
10
11
12
13
<?php

$str = str_repeat('ABCDE', 4);

$chunk_length = 4;
$chunks = str_split($str, $chunk_length);
$last = end($chunks);
if (strlen($last) === $chunk_length) {
    $chunks[] = '';
}
$str_with_spaces = implode(' ', $chunks);

echo '-->', $str_with_spaces, '<--';


Output:
1
-->ABCD EABC DEAB CDEA BCDE <--


Create a new paste based on this one


Comments:
posted by dddddddddddd on Dec 5
dddddddddddddddddd
reply
posted by dddddddddddd on Dec 5
ddddd
reply