Re: First Character of a string.
| From: | Jitterbug | Date: | Mon, 09 Oct 2000 02:52:29 +0000 |
| Subject: | Re: First Character of a string. | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-19136@lists.php.net to get a copy of this message | ||
On Sun, 8 Oct 2000 19:19:05 +0100, you wrote:
>
>> <?
>> $firstname ="Brian";
>> $firstinitial="
>> ?>
>> here i want to parse out just the B from Brian with out hard coding it in
>> <?
>> ";
>> echo $firstname,"<BR>";
>> echo $firstinitial,"<BR>";
>> ?>
>
>$firstinitial= substr($firstname,1,1);
>
>James
should be
$firstinitial = substr($firstname,0,1);
I like
$firstinitial = $firstname[0];
better though. Much cleaner.