I needed a function that could split a string from the end with any left over chunk being at the beginning of the array (the beginning of the string).
<?php
function str_rsplit($str, $sz)
{
if ( !$sz ) { return false; }
if ( $sz > 0 ) { return str_split($str,$sz); } $l = strlen($str);
$sz = min(-$sz,$l);
$mod = $l % $sz;
if ( !$mod ) { return str_split($str,$sz); } return array_merge(array(substr($str,0,$mod)), str_split(substr($str,$mod),$sz));
}
$str = 'aAbBcCdDeEfFg';
str_split($str,5); str_rsplit($str,5); str_rsplit($str,-5); ?>