Re: beginner: cut text after " "

From: Date: Thu, 28 Aug 2003 04:54:30 +0000
Subject: Re: beginner: cut text after " "
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-161004@lists.php.net to get a copy of this message
On Wed, 27 Aug 2003 21:30:25 -0700, you wrote: >Want to remove the string after the first whitespace like: > >"here is a text what i have" >to: >"here" I'd explode() the string into an array, and take the 0th element of the array. $s = 'here is a text what i have'; $a = explode (' ', $s); echo ($a[0]); If you want to match /whitespace/ (tab, space, etc), replace explode() with split() using the correct regular expression. (Note: explode() takes a 3rd optional parameter, limit, if you want a remainder string, too.)

« previous php.general (#161004) next »