php str_replace多个参数,php str_replace()函数的用法,有那些参数?
范例
例 2329. str_replace() examples
// Provides:
$bodytag = str_replace("%body%", "black", "
");// 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
// Order of replacement
$str = "Line 1\nLine 2\rLine 3\r\nLine 4\n";
$order = array("\r\n", "\n", "\r");
$replace = '
';
// Processes \r\n's first so they aren't converted twice.
$newstr = str_replace($order, $replace, $str);
// Outputs: apearpearle pear
$letters = array('a', 'p');
$fruit = array('apple', 'pear');
$text = 'a p';
$output = str_replace($letters, $fruit, $text);
echo $output;
?>
總結(jié)
以上是生活随笔為你收集整理的php str_replace多个参数,php str_replace()函数的用法,有那些参数?的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php 文件保存函数,PHP文件函数
- 下一篇: 用java智能锁远程,从生产者-消费者模