炒炒冷饭。 我上次看见有人用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 求一个加验证是否含有标签并去掉标签得到值的函数标签[en][/en] && || 的用法 对字符串如何转化成Uniqueidentifier类型的数据 我想在租借的虚拟主机上使用PEAR,要怎么办呢 请教正则表达式写法 连接数据库的方式 unset($_SESSION['username'])注销不了。郁闷! cookie 可以被盗走么? 安全不? 高手请进:PHP 程序完成向一需要用户登录的网站发布信息的功能 关于session_set_cookie_params()函数的一个问题。 访问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