note 69327 added to function.preg-split
| From: | be2 dot php dot net at alan-smith dot no-ip dot com | Date: | Thu, 31 Aug 2006 18:42:19 +0000 |
| Subject: | note 69327 added to function.preg-split | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-116558@lists.php.net to get a copy of this message | ||
This script changes 1 line to multi-lines, with $max_size as the max size of the line.
<?
$max_size = 70
$str = "Test - Test - Test - Test - Test - Test - Test - Test - Test - Test - Test - Test -
Test - Test - Test - Test - Test - Test - Test - Test - Test - Test";
$keywords = preg_split("/[\s,]+/", $str, -1, PREG_SPLIT_OFFSET_CAPTURE);
foreach($keywords as $msg){
$line[(floor($msg[1]/$max_size))].= $msg[0].' ';
}
print_r ($line);
//Array
//(
// [0] => Test - Test - Test - Test - Test - Test - Test - Test - Test - Test -
// [1] => Test - Test - Test - Test - Test - Test - Test - Test - Test - Test -
// [2] => Test - Test
//)
?>
----
Server IP: 193.190.198.20
Probable Submitter: 85.10.81.247
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.preg-split.php
Edit -- https://master.php.net/note/edit/69327
Del: integrated -- https://master.php.net/note/delete/69327/integrated
Del: useless -- https://master.php.net/note/delete/69327/useless
Del: bad code -- https://master.php.net/note/delete/69327/bad+code
Del: spam -- https://master.php.net/note/delete/69327/spam
Del: non-english -- https://master.php.net/note/delete/69327/non-english
Del: in docs -- https://master.php.net/note/delete/69327/in+docs
Del: other reasons-- https://master.php.net/note/delete/69327
Reject -- https://master.php.net/note/reject/69327
Search -- https://master.php.net/manage/user-notes.php