Re: Splitting a line of text

From: Date: Thu, 14 Sep 2000 08:26:21 +0000
Subject: Re: Splitting a line of text
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-16738@lists.php.net to get a copy of this message
pour@mieterra.com (Andreas Pour) writes: > Franklin van Velthuizen wrote: > > > > > Hi all. Is there any way that I can insert a new line (<br>\n) into a > > string > > > every 45 characters? > > > > take a look at > > http://uk.php.net/manual/html/function.wordwrap.html > > > > $text = wordwrap($text, 45, "<br>\n") should do the trick, I guess > > Hi, > > I think wordwrap moves back to the first white space before the xth > character. To put one exactly every 45 characters, you need something > like: > > $text = ereg_replace("(.{45})", "\\1\n", $orig); This would be considerably faster... $text = chunk_split($text, 45, "<br>\n"); -- Robin Vickery............................................... Planet-Three, 3A West Point, Warple Way, London, W3 0RG, UK Email: robin@planet-three.net Phone: +44 (0)870 729 5444

« previous php.general (#16738) next »