I am trying to split a string into 1, 2 and 3 segments.
For example, I have this:
$str = 'test';
$arr1 = str_split($str);
foreach($arr1 as $ar1) {
echo strtolower($ar1).' ';
}
Which works well when splitting 1 character, I get:
t e s t
However, when I try:
$arr2 = str_split($str, 2);
I get:
te st
Is there any way that I can output this?
te es st
and then also with 3 characters like this?
tes est
source
share