Re: First Character of a string.

From: Date: Mon, 09 Oct 2000 21:20:40 +0000
Subject: Re: First Character of a string.
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-19241@lists.php.net to get a copy of this message
Jitterbug wrote: > > 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]; Using this method, can I get the first 3 chars? $firstinitial = substr($firstname,0,3); $firstinitial = $firstname[?]; -- Kind regards Kevin Waterson

« previous php.general (#19241) next »