Re: [PHP] First Character In A String

2007-01-21 Thread Robert Cummings
On Sun, 2007-01-21 at 16:49 +0100, Jochem Maas wrote: > now we can get on with having a flame war as to the 'best' way to style > your code, because obviously this is better ;-) ... Game on! :B > echo trim(substr((string)$forename, 0, 1).' '.$surname); Surely any fool can see that yours is infer

Re: [PHP] First Character In A String

2007-01-21 Thread Jochem Maas
Robert Cummings wrote: > On Sun, 2007-01-21 at 16:27 +0100, Jochem Maas wrote: >> Robert Cummings wrote: >>> On Sun, 2007-01-21 at 16:02 +0100, Jochem Maas wrote: >>> $initial = (is_string($forename) && strlen($forename) > 0) ? $forename[0] : '' ; echo

Re: [PHP] First Character In A String

2007-01-21 Thread Robert Cummings
On Sun, 2007-01-21 at 16:27 +0100, Jochem Maas wrote: > Robert Cummings wrote: > > On Sun, 2007-01-21 at 16:02 +0100, Jochem Maas wrote: > >> >> > >> $initial = (is_string($forename) && strlen($forename) > 0) > >> ? $forename[0] > >> : '' > >> ; > >> > >> echo trim($initial.' '.$surnam

Re: [PHP] First Character In A String

2007-01-21 Thread Jochem Maas
Robert Cummings wrote: > On Sun, 2007-01-21 at 16:02 +0100, Jochem Maas wrote: >> > >> $initial = (is_string($forename) && strlen($forename) > 0) >> ? $forename[0] >> : '' >> ; >> >> echo trim($initial.' '.$surname); >> >> ?> > > That sure is verbose Jochem... agreed, it was don

Re: [PHP] First Character In A String

2007-01-21 Thread Robert Cummings
On Sun, 2007-01-21 at 16:02 +0100, Jochem Maas wrote: > > > $initial = (is_string($forename) && strlen($forename) > 0) >? $forename[0] >: '' >; > > echo trim($initial.' '.$surname); > > ?> That sure is verbose Jochem... Cheers, Rob. -- .--

Re: [PHP] First Character In A String

2007-01-21 Thread Jochem Maas
Christopher Deeley wrote: > Can anyone tell me if there is a function to return the first letter in a > string, such as: > > $surname="SMITH"; > $forename="ALAN"; > > Is there a function which I can use to make $forename "A", so I can display > it as A SMITH? another alternative to the other ans

Re: [PHP] First Character In A String

2007-01-21 Thread Nicholas Yim
Hello Christopher Deeley, Best regards, === At 2007-01-21, 21:49:06 you wrote: === >Can anyone tell me if there is a function to return the first letter in a >string, such as: > >$surname="SMITH"; >$forename="ALAN"; > >Is there a function which I can use to make $forename "A", so I

RE: [PHP] First Character In A String

2007-01-21 Thread Peter Lauri
, January 21, 2007 3:44 PM To: php-general@lists.php.net Subject: [PHP] First Character In A String Can anyone tell me if there is a function to return the first letter in a string, such as: $surname="SMITH"; $forename="ALAN"; Is there a function which I can use to make $forename &

[PHP] First Character In A String

2007-01-21 Thread Christopher Deeley
Can anyone tell me if there is a function to return the first letter in a string, such as: $surname="SMITH"; $forename="ALAN"; Is there a function which I can use to make $forename "A", so I can display it as A SMITH? Thank You In Advance