| px | top | add code | search | signup | login | help |
<?php
function php4_str_split ($string) {
// don't proceed if the string is empty
if (empty ($string) || strlen ($string) < 1) return false;
// check to see if PHP 5+ really exists
// if so, use it's str_split function. :)
if (function_exists ('str_split')) {
return str_split ($string);
}
// PHP 4 version
// we'll store the result in this array
$arr_string = array();
// iterate over all the string's characters
for ($i=0; $i<strlen($string); $i++) {
// push current character onto our return array
$arr_string[] = $string{$i};
}
// return finished array
return $arr_string;
}
?>
Comments or questions?
PX is running PHP 5.2.11
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.