Home > Backend Development > PHP Tutorial > 例子:php的substr函数真是强大(substr.php3)_PHP

例子:php的substr函数真是强大(substr.php3)_PHP

WBOY
Release: 2016-06-01 12:36:24
Original
854 people have browsed it

SUBSTR


$rest = substr("abcdef", 1); // returns "bcdef"
echo 'substr("abcdef", 1) returns ' . $rest . "
";
$rest = substr("abcdef", 1, 3); // returns "bcd"
echo 'substr("abcdef", 1, 3) returns ' . $rest . "
";
$rest = substr("abcdef", -1); // returns "f"
echo 'substr("abcdef", -1) returns ' . $rest . "
";
$rest = substr("abcdef", -2); // returns "ef"
echo 'substr("abcdef", -2) returns ' . $rest . "
";
$rest = substr("abcdef", -3, 1); // returns "d"
echo 'substr("abcdef", -3, 1) returns ' . $rest . "
";
$rest = substr("abcdef", 1, -1); // returns "bcde"
echo 'substr("abcdef", 1, -1) returns ' . $rest . "
";
?>

具体的使用可以看PHP的Manual中的function.substr.html。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template