note 47120 deleted from function.str-split by aidan
| From: | aidan@php.net | Date: | Sat, 08 Jan 2005 01:07:53 +0000 |
| Subject: | note 47120 deleted from function.str-split by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-82942@lists.php.net to get a copy of this message | ||
Note Submitter: PEAR::Package::Php_Compat
----
For PHP<5, use this function from PEAR::Package::PHP_Compat
<?php
if (!function_exists('str_split')) {
function str_split($string, $split_length = 1) {
if (!is_numeric($split_length)) {
trigger_error('str_split() expects parameter 2 to be long, ' .
gettype($split_length) . ' given', E_USER_WARNING);
return false;
}
if ($split_length < 1) {
trigger_error('str_split() The the length of each segment must be greater then
zero', E_USER_WARNING);
return false;
}
preg_match_all('/.{1,' . $split_length . '}/s', $string, $matches);
return $matches[0];
}
}
?>