substrPHP ManualPrevNextsubstrsubstr -- Return part of a stringDescriptionstring substr(string string, int start, int
[length]
);
Substr returns the portion of string
specified by the start and
length parameters.
If start is positive, the returned string
will start at the start'th character of
string.
Examples:
1
2 $rest = substr ("abcdef", 1); // returns "bcdef"
3 $rest = substr ("abcdef", 1, 3); // returns "bcd"
4
If start is negative, the returned string
will start at the start'th character
from the end of string.
Examples:
1
2 $rest = substr ("abcdef", -1); // returns "f"
3 $rest = substr ("abcdef", -2); // returns "ef"
4 $rest = substr ("abcdef", -3, 1); // returns "d"
5
If length is given and is positive, the
string returned will end length characters
from start. If this would result in a
string with negative length (because the start is past the end of
the string), then the returned string will contain the single
character at start.
If length is given and is negative, the
string returned will end length characters
from the end of string. If this would
result in a string with negative length, then the returned string
will contain the single character at
start.
Examples:
1
2 $rest = substr ("abcdef", 1, -1); // returns "bcde"
3
See also strrchr() and
ereg().
PrevHomeNextstrtrUpsubstr_replace
Wyszukiwarka
Podobne podstrony:
function substr countfunction substr replacefunction substr replacefunction substr replacefunction substrfunction substrfunction substr countfunction mb substr countfunction mb substrfunction mb substrfunction fdf next field namefunction ccvs voidfunction mysql errorfunction mcal event set endfunction mcrypt cbcwięcej podobnych podstron