note 80979 deleted from function.str-split by danbrown

From: Date: Mon, 04 Aug 2008 15:34:37 +0000
Subject: note 80979 deleted from function.str-split by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-143139@lists.php.net to get a copy of this message
Note Submitter: info at marc-gutt dot de ---- Don't use count() or strlen() directly in for, while, etc. as it is performed in every loop! Besides I'm using this version: if( !function_exists('str_split') ) { function str_split($string, $split_length=1) { $array = array(); $len = strlen($string); do { $part = ''; for ($j = 0; $j < $split_length; $j++) { $part .= $string{$i}; $i++; } $array[] = $part; } while ($i < $len); return $array; } }

« previous php.notes (#143139) next »