note 57852 added to function.str-split

From: Date: Sun, 16 Oct 2005 20:34:02 +0000
Subject: note 57852 added to function.str-split
Groups: php.notes 
Request: Send a blank email to php-notes+get-97092@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/function.str-split.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+57852 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57852&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57852&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57852&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57852&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57852&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57852&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57852&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+57852&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#97092) next »