note 79921 deleted from function.str-split by crell

From: Date: Wed, 29 Jun 2022 18:30:38 +0000
Subject: note 79921 deleted from function.str-split by crell
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-218688@lists.php.net to get a copy of this message
Note Submitter: rlpvandenberg at hotmail dot com ---- The previous suggestion is almost correct (and will only working for strlen=1. The working PHP4 function is: <code> function str_split($text, $split = 1){ //place each character of the string into and array $array = array(); for ($i=0; $i < strlen($text); $i++){ $key = ""; for ($j = 0; $j < $split; $j++){ $key .= $text[$i+$j]; } $i = $i + $j - 1; array_push($array, $key); } return $array; } </code>

« previous php.notes (#218688) next »