note 63139 added to function.str-split

From: Date: Tue, 14 Mar 2006 13:49:24 +0000
Subject: note 63139 added to function.str-split
Groups: php.notes 
Request: Send a blank email to php-notes+get-105786@lists.php.net to get a copy of this message
Note to function by carlosreche at yahoo dot com. The while: <?php ... while ($str_length--) { $splitted[$i] = $string[$i++]; } ... ?> .. result in index starting at 1. Ie: str_split("ABC") gives Array ( [1] => A [2] => B [3] => C ) While php5's str_split("ABC") gives Array ( [0] => A [1] => B [2] => C ) And his str_split("ABC",2) gives index starting at 0. Change to this (or something similar): <?php ... while ($str_length--) { $splitted[$i] = $string[$i]; $i++; } ... ?> .... or use heavyraptor's function. A bit more sclick,.. ---- Server IP: 85.19.135.21 Probable Submitter: 80.203.38.24 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.str-split.php Edit -- http://master.php.net/note/edit/63139 Del: integrated -- http://master.php.net/note/delete/63139/integrated Del: useless -- http://master.php.net/note/delete/63139/useless Del: bad code -- http://master.php.net/note/delete/63139/bad+code Del: spam -- http://master.php.net/note/delete/63139/spam Del: non-english -- http://master.php.net/note/delete/63139/non-english Del: in docs -- http://master.php.net/note/delete/63139/in+docs Del: other reasons-- http://master.php.net/note/delete/63139 Reject -- http://master.php.net/note/reject/63139 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#105786) next »