炒炒冷饭。 我上次看见有人用str_replace 替换是可以写成数组的,,给点资料,连接来看看吧 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 由 str_replace 函数声明mixed str_replace ( mixed search, mixed replace, mixed subject [, int &count] )可知,替换是可以写成数组的类型 mixed 自然是包括 数组 的手册中已经给出了示例代码,不需要再找了吧?<?php// Provides: <body text='black'>$bodytag = str_replace("%body%", "black", "<body text='%body%'>");// Provides: Hll Wrld f PHP$vowels = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U");$onlyconsonants = str_replace($vowels, "", "Hello World of PHP");// Provides: You should eat pizza, beer, and ice cream every day$phrase = "You should eat fruits, vegetables, and fiber every day.";$healthy = array("fruits", "vegetables", "fiber");$yummy = array("pizza", "beer", "ice cream");$newphrase = str_replace($healthy, $yummy, $phrase);// Use of the count parameter is available as of PHP 5.0.0$str = str_replace("ll", "", "good golly miss molly!", $count);echo $count; // 2?> 看错了,原来我的意思是strtr这个函数实现的 $trans = array("hello" => "hi", "hi" => "hello");echo strtr("hi all, I said hello", $trans);hello all, I said hi 手机登陆网站如何获取手机操作系统及手机型号?? 再次遭遇PHP对MYSQL插入中文和显示时出现乱码 关于表但提交问题! 获取网址正则怎么搞? 有了解OSCOMMERCE,从模块化的角度谈一下OSCOMMERCE V1,V2,V3的去边好吗 php高手请指教新手!php实现工程牌游戏当中多个用户同一界面的交互 在PHP & MySQL 中怎样实现分页技术 activex控件用html代码怎样实现? mysql中如何更改一个字段类型,急 如何在php中使用treeview控件? 访问PHP数据库,mysql 这个delete删除 哪里错误了?
mixed str_replace ( mixed search, mixed replace, mixed subject [, int &count] )
可知,替换是可以写成数组的类型 mixed 自然是包括 数组 的手册中已经给出了示例代码,不需要再找了吧?
<?php
// Provides: <body text='black'>
$bodytag = str_replace("%body%", "black", "<body text='%body%'>");// Provides: Hll Wrld f PHP
$vowels = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U");
$onlyconsonants = str_replace($vowels, "", "Hello World of PHP");// Provides: You should eat pizza, beer, and ice cream every day
$phrase = "You should eat fruits, vegetables, and fiber every day.";
$healthy = array("fruits", "vegetables", "fiber");
$yummy = array("pizza", "beer", "ice cream");$newphrase = str_replace($healthy, $yummy, $phrase);// Use of the count parameter is available as of PHP 5.0.0
$str = str_replace("ll", "", "good golly miss molly!", $count);
echo $count; // 2
?>
echo strtr("hi all, I said hello", $trans);
hello all, I said hi