Home > php教程 > php手册 > body text

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

WBOY
Release: 2016-06-21 09:13:44
Original
751 people have browsed it

函数


$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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!