php字符串函数学习之strstr()

时间:2021-05-26

复制代码 代码如下:
<?php

$str = "。规定的被搜索的字符串 ";
$s = "的";
echo strstr($str,$s) . "<br/>";
echo mb_strstr($str,$s, 'utf-8') . "<br/>";
echo mb_strstr($str,$s, true, 'utf-8') . "<br/>";
echo mb_strstr($str,$s, false, 'utf-8') . "<hr/>";


echo strrchr($str,$s) . "<br/>";
echo mb_strrchr($str,$s, 'utf-8') . "<br/>";
echo mb_strrchr($str,$s, true, 'utf-8') . "<br/>";
echo mb_strrchr($str,$s, false, 'utf-8') . "<hr/>";

$str = "Hello world!Hello world!";
$s = "world";
echo strrchr($str,$s) . "<br/>";
echo mb_strrchr($str,$s, 'utf-8') . "<br/>";
echo mb_strrchr($str,$s, true, 'utf-8') . "<br/>";
echo mb_strrchr($str,$s, false, 'utf-8') . "<hr/>";


echo strtr("Hilla Warld","ia","eo"). "<br/>";
$arr = array("Hello" => "Hi", "world" => "earth");
echo strtr("Hello world",$arr). "<hr/>";

echo strtr("如果省略,则使用内部字符编码","内部","外部"). "<br/>";
$arr = array("如果" => "若", "则" => "那么");
echo strtr("如果省略,则使用内部字符编码",$arr). "<hr/>";
?>

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章