note 78910 deleted from function.str-split by crell
| From: | crell@php.net | Date: | Wed, 29 Jun 2022 18:28:29 +0000 |
| Subject: | note 78910 deleted from function.str-split by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218677@lists.php.net to get a copy of this message | ||
Note Submitter: dacmeaux at gmail dot com
----
I was looking for a function that would split a string into an array like str_split() and found
Razor's function above. Just though that I would simplify the code a little.
<?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); $i++){
$key = NULL;
for ($j = 0; $j < $split; $j++){
$key .= $text[$i];
}
array_push($array, $key);
}
return $array;
}
?>
Both mine and worksRazor's work well, I just prefer to use less code. I could have written one
myself, but I was just being lazy.