note 37501 deleted from function.str-split by aidan
| From: | aidan@php.net | Date: | Tue, 01 Jun 2004 06:18:09 +0000 |
| Subject: | note 37501 deleted from function.str-split by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-70386@lists.php.net to get a copy of this message | ||
Note Submitter: Paul Gregg / Qube #efnet
----
A neat solution for older versions of PHP is:
http://www.pgregg.com/projects/php/code/str_split.phps
(I had wrote this as strsplit() before I found out str_split() existed, so I renamed mine):
/*
* split a string up into equal sized chunks
*
* Paul Gregg <pgregg@pgregg.com>
* 23 September 2003
*
* Open Source Code: If you use this code on your site for public
* access (i.e. on the Internet) then you must attribute the author and
* source web site: http://www.pgregg.com/projects/php/code/str_split.phps
* str_split is available from PHP version 5 by default
*
*/
if (!function_exists('str_split')) {
Function str_split($string, $chunksize=1) {
preg_match_all('/('.str_repeat('.', $chunksize).')/Uims', $string,
$matches)
;
return $matches[1];
}
}