note 57852 deleted from function.str-split by aidan
| From: | aidan@php.net | Date: | Sat, 04 Feb 2006 07:13:55 +0000 |
| Subject: | note 57852 deleted from function.str-split by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-102961@lists.php.net to get a copy of this message | ||
Note Submitter: ludvig dot ericson at gmail dot com
----
It seems that most the str_split imitations around here are pretty weird.
chunk_split can be used for the exact same purpose:
<?php
if (!function_exists('str_split')) {
function str_split($string, $split_length = 1) {
return explode("\r\n", chunk_split($string, $split_length));
}
}
?>
I would not say that it is beautiful, yet it is not as insane as that unpack thing down a few
comments.
You can probably improve it by checking $split_length and such, but this Just works (tm) and I doubt
that you ever call it with a negative $split_length anyway... Unless you are insane of course.