您的位置:首页 > 其它

str_replace函数应用

2015-12-14 22:20 239 查看
<?php
//mixed  str_replace  ( mixed  $search  , mixed  $replace  , mixed  $subject  [, int &$count  ] )
//在$subject中用$replace替换$search ,最后返回替换后的字符串和[替换的次数];

$str='This is a test , This is a real test , hello world';
$str=str_replace('test', 'show time', $str, $count);
echo $str;     //输出替换后的字符串 This is a show time , This is a real show time , hello world
echo '<hr/>';
echo $count;   //输出被替换的次数 2

?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: