note 78910 added to function.str-split
| From: | dacmeaux at gmail dot com | Date: | Thu, 01 Nov 2007 21:57:44 +0000 |
| Subject: | note 78910 added to function.str-split | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-131923@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 64.71.164.2
Probable Submitter: 68.211.60.91
----
Manual Page -- http://www.php.net/manual/en/function.str-split.php
Edit -- https://master.php.net/note/edit/78910
Del: integrated -- https://master.php.net/note/delete/78910/integrated
Del: useless -- https://master.php.net/note/delete/78910/useless
Del: bad code -- https://master.php.net/note/delete/78910/bad+code
Del: spam -- https://master.php.net/note/delete/78910/spam
Del: non-english -- https://master.php.net/note/delete/78910/non-english
Del: in docs -- https://master.php.net/note/delete/78910/in+docs
Del: other reasons-- https://master.php.net/note/delete/78910
Reject -- https://master.php.net/note/reject/78910
Search -- https://master.php.net/manage/user-notes.php