note 80003 added to function.split
| From: | SvetoslavMarinov at osu1 dot php dot net | Date: | Sun, 23 Dec 2007 20:45:11 +0000 |
| Subject: | note 80003 added to function.split | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-133904@lists.php.net to get a copy of this message | ||
Sometimes it is useful to split a string by every character as you can do with Perl:
my @a = split('', 'abc');
/**
* @desc Splits the string by each char
* @param string
* @param int
* @return array
* @author Svetoslav Marinov <svetoslavm AT gmail.com>
*/
function dev_split($str, $max = 7) {
$data = array();
if (strlen($str) < $max) {
$max = strlen($str);
}
// pic a char at a time.
for ($i = 0; $i < $max; $i++) {
$data[] = substr($str, $i, 1);
}
return $data;
}
----
Server IP: 66.207.199.35
Probable Submitter: 24.150.6.242
----
Manual Page -- http://www.php.net/manual/en/function.split.php
Edit -- https://master.php.net/note/edit/80003
Del: integrated -- https://master.php.net/note/delete/80003/integrated
Del: useless -- https://master.php.net/note/delete/80003/useless
Del: bad code -- https://master.php.net/note/delete/80003/bad+code
Del: spam -- https://master.php.net/note/delete/80003/spam
Del: non-english -- https://master.php.net/note/delete/80003/non-english
Del: in docs -- https://master.php.net/note/delete/80003/in+docs
Del: other reasons-- https://master.php.net/note/delete/80003
Reject -- https://master.php.net/note/reject/80003
Search -- https://master.php.net/manage/user-notes.php