Blogger Information
Blog 48
fans 0
comment 0
visits 36469
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
字符串替换
雨天的博客
Original
676 people have browsed it

实例

<?php
/**
 * 字符串查找并替换 str_replace substr_replace
 */
//str_replace(替换后值,被替换值,字符串)
$str = 'I love php, I love php too!';
echo str_replace('php','html5',$str).'<br>';
//删除式替换
echo str_replace(',','',$str).'<br>';
//str_ireplace() 不区分大小写
echo str_ireplace('i','my',$str).'<br>';

//substr_replace(字符串,被替换值,起始位置,长度)
echo substr_replace($str,'喜欢',2,4).'<br>';
//删除式替换
echo substr_replace($str,'',10,1).'<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!