Blogger Information
Blog 48
fans 0
comment 0
visits 36381
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
获取子字符串-2018.08.27作业
雨天的博客
Original
564 people have browsed it

实例

<?php
/**
 * 三个最常用的子串查询
 */
//1.substr($str,n,n) 字符串|起始位置|获取长度  根据位置查询
$str = 'It\'s important to remember that this function does NOT replace newlines with tags.';
echo substr($str,5);
echo '<br>';
echo substr($str,5,11);
echo '<br>';
echo substr($str,-5);//负数表示从尾部开始取保留
echo '<br>';

//strstr($str,start,bool) 字符串|查找位置字符|true
echo strstr($str,'important');//保留查询字符串后面所有的字符
echo '<br>';
echo strstr($str,'important',true); //保留查询字符之前的字符
echo '<br>';

//strpos()
echo strpos($str,'remember');//查询字符串出现的位置
echo '<br>';

运行实例 »

点击 "运行实例" 按钮查看在线实例


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!