note 79503 added to function.str-split

From: Date: Fri, 30 Nov 2007 17:16:37 +0000
Subject: note 79503 added to function.str-split
Groups: php.notes 
Request: Send a blank email to php-notes+get-132695@lists.php.net to get a copy of this message
dacmeaux at gmail dot com's version might work well for a $split value of 1, but above that, it just repeats the one character per array field and based on the $split value. The following does it right: <?php function str_split_php4( $text, $split = 1 ) { // place each character of the string into and array $array = array(); for ( $i=0; $i < strlen( $text ); ){ $key = NULL; for ( $j = 0; $j < $split; $j++, $i++ ) { $key .= $text[$i]; } array_push( $array, $key ); } return $array; } ?> ---- Server IP: 217.13.201.10 Probable Submitter: 80.142.55.103 ---- Manual Page -- http://www.php.net/manual/en/function.str-split.php Edit -- https://master.php.net/note/edit/79503 Del: integrated -- https://master.php.net/note/delete/79503/integrated Del: useless -- https://master.php.net/note/delete/79503/useless Del: bad code -- https://master.php.net/note/delete/79503/bad+code Del: spam -- https://master.php.net/note/delete/79503/spam Del: non-english -- https://master.php.net/note/delete/79503/non-english Del: in docs -- https://master.php.net/note/delete/79503/in+docs Del: other reasons-- https://master.php.net/note/delete/79503 Reject -- https://master.php.net/note/reject/79503 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#132695) next »