Home > Archive > PHP DB > April 2004 > Re: [PHP-DB] First letter
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: [PHP-DB] First letter
|
|
|
|
| Cornelia Boenigk 2004-04-27, 8:56 pm |
| Hi Matt
You can teat a string like an Array
$first = $string[0];
$second = $string[1]
and so on.
Regards
Conni
| |
| George Patterson 2004-04-27, 8:56 pm |
| On Tue, 27 Apr 2004 16:05:32 -0700 (PDT)
"Daniel Clark" <dclark@nwlink.com> wrote:
[color=darkred]
> $rest = substr("abcdef", 1, 3); // returns "bcd"
>
> http://www.phpbuilder.com/manual/function.substr.php
>
>
Or to properly answer the question,
$letter=substr("abc", 0, 1); // returns the first character which is a.
Unless Matt wanted the first letter as opposed to the first character??
George Patterson
| |
| holmes072000@charter.net 2004-04-27, 10:35 pm |
| > From: matthew perry <mwperry@mail.uh.edu>
> What PHP function returns just the first letter of a string?
echo substr($str,0,1);
or
echo $str{0};
---John Holmes...
| |
| Lang Sharpe 2004-04-28, 11:52 pm |
| Cornelia Boenigk wrote:
> Hi Matt
>
> You can teat a string like an Array
> $first = $string[0];
> $second = $string[1]
> and so on.
Actually this method is deprecated. The current best way is to use curly
braces.
$first = $string{0};
$second = $string{1};
Lang
|
|
|
|
|