PHP 起步篇 互动版

在线工具推荐: Three.js AI纹理开发包 - YOLO合成数据生成器 - GLTF/GLB在线编辑 - 3D模型格式在线转换 - 可编程3D场景编辑器

str_ireplace

  _strireplace()函数将指定字符串替换为另外一个指定的字符串。语法格式为:

str_ireplace(string  search, string replace,string subject [,int &count])

  其中参数search为指定要查找的字符串;replace为指定替换的值;subject为指定查找的范围;count为可选参数,获取执行替换的数量。

<?php
$a='i am A student.';
$c=0;
echo str_ireplace("i am A","I am a",$a);  //I an a student.
echo str_ireplace("t","T",$a,$c);  //I am A sTudenT.
echo $c;                            //2
?>

  另外关于字符串处理的函数还有很多,这里就不在逐一介绍,有兴趣的同学再查一下资料吧!