note 63612 deleted from function.str-split by crell
| From: | crell@php.net | Date: | Wed, 29 Jun 2022 17:55:48 +0000 |
| Subject: | note 63612 deleted from function.str-split by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218666@lists.php.net to get a copy of this message | ||
Note Submitter: user at mockme dot com
----
found this great example on a php board for those not using php5, as an alternative to the posts
below this
<?php
if(!function_exists('str_split')){
function str_split($string,$split_length=1){
$count = strlen($string);
if($split_length < 1){
return false;
} elseif($split_length > $count){
return array($string);
} else {
$num = (int)ceil($count/$split_length);
$ret = array();
for($i=0;$i<$num;$i++){
$ret[] = substr($string,$i*$split_length,$split_length);
}
return $ret;
}
}
}
?>