高手帮我看下这段程序怎么没有实现替代的效果
<?php
$text="this is a link to http://www.wjgilmore.com/.";
echo ereg_replace("http://([a-zA-Z0-9./-]+)$","<a href=\"\\0\">\\0</a>",$text);
?>
我的目的是显示带有<a http://www.wjgilmore.com>http://www.wjgilmore.com</a>
<?php
$text="this is a link to http://www.wjgilmore.com/.";
echo ereg_replace("http://([a-zA-Z0-9./-]+)$","<a href=\"\\0\">\\0</a>",$text);
?>
我的目的是显示带有<a http://www.wjgilmore.com>http://www.wjgilmore.com</a>
解决方案 »
- 100分求如何实现点击按钮后,从MYSQL数据库导出XLS文件并提示下载另存
- urlencode问题
- 乱码,还是乱码!!!!
- PHP远程调用Matlab
- 写了个判断一个数组里面是否有重复的内容的函数 大家给点意见 看是否有更高效率的写法 或是我哪里命名不规范==
- 那为大哥知道解决啊..帮帮忙!!Win32下apache2 用get方法传递中文参数会出错 test.php?a=".urlencode(你好)."&b=".urlencode(你也好)
- 关于搜索数据库时间的问题 -- 急!!
- 急急急!!!对于象top这样的不会立即返回的命令的问题,哪位大虾能给个完整的页面程序
- 请版主和高手指教,在线选课系统机制和模式,哪里有实例,特急,在线等
- 上传后图片显示的要么不完整,要么质量下降,是什么原因。
- PHP实现excel导出成xml格式
- 急!!!!问大家一个sql
$subject = "abcdef";
$pattern = '/^def/';
preg_match($pattern, $subject, $matches, PREG_OFFSET_CAPTURE, 3);
print_r($matches);
?>
$r = "<a href=\"\\0\">\\0</a>";$t = "this is a link http://asdf.asdf.asdf/";echo preg_replace($p,$r,$t);
echo ereg_replace("http://[a-zA-Z0-9./-]+[^/.]/","<a href=\"\\0\">\\0</a>",$text);this is a link to <a href="http://www.wjgilmore.com">http://www.wjgilmore.com</a>.你本身的也是正确的,只不过格式上有点问题
echo ereg_replace("http://([a-zA-Z0-9./-]+)$","<a href=\"\\0\">\\0</a>",$text);
得到
this is a link to <a href="http://www.wjgilmore.com/.">http://www.wjgilmore.com/.</a>
对比一下差异,当然这无碍大局