文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>ereg_replace()函数事例教程....

ereg_replace()函数事例教程....

时间:2007-11-13  来源:whxy5


ereg_replace()函数事例教程....
正则表达式函数库
ereg_replace
字符串比对解析并取代。 phpma.com
语法: string ereg_replace(string pattern, string replacement, string string);
返回值: 字符串
函数种类: 资料处理 phpma.com


内容说明
本函数以 pattern 的规则来解析比对字符串 string,欲取而代之的字符串为参数 replacement。返回值为字符串类型,为取代后的字符串结果。


使用范例
[email protected] 在 16-Mar-1999 提出的例子。
'fine',
                  2 => 'overcast',
                  3 => 'rainy' );
while (ereg ('{([0-9]+)}', $text, $regs)) {
  $found = $regs[1];
  $text = ereg_replace("\{".$found."\}", $daytype[$found], $text);
}
echo "$text\n";
// This is a fine day, not overcast and rainy.
?>

[email protected] 并同时提出具有相同功能的perl 程序范例如下:
$text = 'This is a {1} day, not {2} and {3}.';
%daytype = ( 1 => 'fine',phpma.com
             2 => 'overcast',
             3 => 'rainy' );
$text =~ s/{(\d+)}/$daytype{$1}/eg;
print "$text\n";


相关阅读 更多 +
排行榜 更多 +
模拟梦幻人生 v2.0.1 安卓版

模拟梦幻人生 v2.0.1 安卓版

飞行射击 下载
模拟梦幻人生 v2.0.1 安卓版

模拟梦幻人生 v2.0.1 安卓版

飞行射击 下载
模拟梦幻人生 v2.0.1 安卓版

模拟梦幻人生 v2.0.1 安卓版

飞行射击 下载