Method Signature
string substr ( string $string , int $start [, int $length ] )
Parameter Description
string => Required. Specifies the string to return a part of.start => Required. Specifies where to start in the string.
- A positive number - Start at a specified position in the string.
- A negative number - Start at a specified position from the end of the string.
- 0 - Start at the first character in string.
- A positive number - The length to be returned from the start parameter.
- Negative number - The length to be returned from the end of the string
Examples
echo substr("Hello world!",6); // world! echo substr("Hello world!",6,5); // world echo substr('abcdef', 1); // bcdef echo substr('abcdef', 1, 3); // bcd echo substr('abcdef', 0, 4); // abcd echo substr('abcdef', 0, 8); // abcdef echo substr('abcdef', -1, 1); // f
0 comments:
Post a Comment