Substr
(PHP3, PHP4)
SUBSTR---&http://www.aliyun.com/zixun/aggregation/37954.html ">nbsp; Get partial string
Syntax: String substr (string string, int start [, int length])
Description:
SUBSTR () returns a part of a string that is specified by the parameter start and length.
If start is a positive number, the returned string will start with the first character of string.
Example:
<?php
$rest = substr ("abcdef", 1); Returns "Bcdef"
$rest = substr ("abcdef", 1, 3); Returns "BCD"
?>
If start is a negative number, the returned string will start at the end of string.
Example:
<?php
$rest = substr ("abcdef",-1); Returns "F"
$rest = substr ("ABCdef",-2); Returns "EF"
$rest = substr ("ABCdef",-3, 1); Returns "D"
?>
If there is a given parameter length and is a positive number, the returned string returns the length character from start.
If there is a given parameter length and is a negative number, the returned string will end at the length of the string at the end.
Example:
<?php
$rest = substr ("abcdef", 1,-1); Returns "BCDE"
?>
Reference: STRRCHR () Ereg ()