- substr: documentation ( source)
- var_export: documentation ( source)
<?php
$string = 'lognstring';
$segmentLength = 3;
$totalLength = strlen($string);
for ($i = 0; $i < $totalLength; $i += $segmentLength) {
$result[] = substr(
$string,
$i > $totalLength - $segmentLength ? $totalLength - $segmentLength : $i,
$segmentLength
);
}
var_export($result);