Re: substr....what does this mean? (newbie)
| From: | Michael Virnstein | Date: | Wed, 22 May 2002 12:22:18 +0000 |
| Subject: | Re: substr....what does this mean? (newbie) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-98731@lists.php.net to get a copy of this message | ||
Hi,
first take a look at this page:
http://www.php.net/manual/en/function.substr.php
> if (substr($text, -1) == ".")
substr($text, -1) will return the last character in string $text.
if it is a "." the if statement will evaluate to true
and it'll do the following
> {$test = substr($text, 0, -1);}
$test = substr($text, 0, -1) will return all characters of $text but the
last one and write them
to $test.
a negative third parameter means ommitting characters from the end of the
string.
The end of the string depends on the second parameter, which tells us where
to start.
if it is positive, start is the start and end is the end of the string,
if it is negative start is the end and end is the start of the string
Regards Michael
P.S. the manual is your friend, learn how to read it!!!
"R" <r@jumac.com> schrieb im Newsbeitrag
news:000701c2015c$fd2e1570$0a6da8c0@lgwezec83s94bn...
> Hi ppl,
> Can you tell me what does this mean?
>
> if (substr($text, -1) == ".")
> {$test = substr($text, 0, -1);}
>
> I know the if part searches the $text from the starting for the "."
> I am just confused about what the second and third arguement does in the
> substr. (Second line)
>
> I know that this is an easy question for you PHP guys out there,
> and I know i will get an answer,
> so I thank you all in advance.
>
> Cheers
> -Ryan A.
>