H M M M
2009-12-31 12:32:23 UTC
The function (http://www.jonasjohn.de/snippets/php/split-by-length.htm) is:
/**
* Splits the given string into chunks with the given length.
*
* @param string $string Input string
* @param string $chunkLength Chunk length
* @return array Splitted string
*/
function SplitByLength($string, $chunkLength=1){
$Result = array();
$Remainder = strlen($string) % $chunkLength;
$cycles = ((strlen($string) - $Remainder) / $chunkLength) + (($Remainder != 0) ? 1 : 0);
for ($x=0; $x < $cycles; $x++)
$Result[$x] = substr($string, ($x * $chunkLength), $chunkLength);
return $Result;
}
I tried:
call_user_func('SplitByLength($sub, $chunkLength=7)');
(($sub is the string I'm trying to cut into pieces by length!)
and
call_user_func('SplitByLength');
Neither work. If someone can explain what needs to be included in this particular function call, and more importantly WHY it needs to be called, that would be great.