note 53756 added to function.str-split

From: Date: Sun, 12 Jun 2005 06:11:30 +0000
Subject: note 53756 added to function.str-split
Groups: php.notes 
Request: Send a blank email to php-notes+get-90283@lists.php.net to get a copy of this message
i found this to be the best solution for emulation of the str_split function if (!function_exists('str_split')){ function str_split($string, $max_length = 1){ for($i = 0, $cur_length = 0, $cur_array = 0, $spl_string = array(0 => ''); isset($string{$i}); $i++, $cur_length++){ if ($cur_length >= $max_length){ $cur_length = 0; $cur_array++; $spl_string[$cur_array] = $string{$i}; } else{ $spl_string[$cur_array] .= $string{$i}; } } return($spl_string); } } ---- Manual Page -- http://www.php.net/manual/en/function.str-split.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+53756 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+53756&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+53756&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+53756&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+53756&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+53756&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+53756&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#90283) next »