Re: counting max word length fails on line brake

From: Date: Wed, 15 May 2002 14:54:40 +0000
Subject: Re: counting max word length fails on line brake
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-97731@lists.php.net to get a copy of this message
You might want to look into wordwrap(), too www.php.net/wordwrap ---John Holmes... ----- Original Message ----- From: "Analysis & Solutions" <danielc@analysisandsolutions.com> To: "PHP List" <php-general@lists.php.net> Sent: Wednesday, May 15, 2002 10:42 AM Subject: Re: [PHP] counting max word length fails on line brake > 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 > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#97731) next »