Re: counting max word length fails on line brake

From: Date: Wed, 15 May 2002 14:42:56 +0000
Subject: Re: counting max word length fails on line brake
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-97730@lists.php.net to get a copy of this message
On Wed, May 15, 2002 at 12:49:30PM +0200, andy wrote: > > test > ölakjdfölakjdöfkjaödlfkjöaksdjföl > > it asumes thtat the word is: test ölakjdfölakjdöfkjaödlfkjöaksdjföl > > $word = explode(" ",$string); Because you're splitting on spaces only. If you want to split on more than just spaces, you need to use a regular expression split function. $word = preg_split('/\s+/', $string); That will split on any whitespace character, such as space, tabs, and line breaks. Note, putting in the + makes the expression kind enough to only do one split in cases where more than one space character are next to each other. Enjoy, --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

« previous php.general (#97730) next »