note 69327 deleted from function.preg-split by tularis

From: Date: Thu, 03 May 2007 22:23:43 +0000
Subject: note 69327 deleted from function.preg-split by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-126169@lists.php.net to get a copy of this message
Note Submitter: be2 dot php dot net at alan-smith dot no-ip dot com ---- 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 //) ?>

« previous php.notes (#126169) next »