标签:
(一)strtr是字符替换函数
(1)单个字符替换:
<?php echo strtr("abba", "ab", "10"),"\n"; echo strtr("baab", "ab", "01"),"\n"; ?>
输出结果为:
(2)字符串对应替换:
<?php $trans = array("ab" => "10"); echo strtr("abba", $trans), "\n"; ?>
输出结果为:
(二)str_replace替换函数,等同于strtr用数组替换:
<?php echo str_replace("ab", "10", "abba"), "\n"; ?>
输出结果为:
标签:
原文地址:http://www.cnblogs.com/anlia/p/5976704.html