Re: Easy question - delete strings from the beginning of space...
| From: | Jordan Miller | Date: | Tue, 20 Sep 2005 15:19:49 +0000 |
| Subject: | Re: Easy question - delete strings from the beginning of space... | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-222783@lists.php.net to get a copy of this message | ||
to get rid of potential double spaces after the explode, you could do:
foreach ($words as $word) {
if (!empty($word)) {
$first = $word;
break;
}
}
echo $first;
This will always return the first word.
Jordan
On Sep 20, 2005, at 7:24 AM, Jochem Maas wrote:
how much easier do you want it? oh and guessing kinda sucks. $str = "Hello World"; $words = explode(" ", $str); echo $words[0]; ... but what if you have double spaces, or a space at the beginning?