【发布时间】:2009-03-05 05:46:30
【问题描述】:
我有一些错误的 MySQL 条目需要修复。我正在尝试在 PHP 中这样做。
我有什么:
a whole bunch of text with no numbers Entry #:2439. a whole bunch of text Click here to blah blah blah
我想要什么:
a whole bunch of text with no numbers Entry #:2439. a whole bunch of text <BR><A href="somepage.php?entry_no=2439">Click here to blah blah blah</A>
我的 PHP 代码:
$fixed = preg_replace('/(.*)(\d*)(.*)(Click here.*)/i',"$1$2$3<BR><A href=\"somepage.php?entry_no=$2\">$4</A>",$originalData);
由于某种原因,这就是我得到的:
a whole bunch of text with no numbers Entry #:2439. a whole bunch of text <BR><A href="somepage.php?entry_no=">Click here to blah blah blah</A>
$2 没有第二次给我这个数字。有人有什么想法吗?
【问题讨论】:
-
不要使用“点击这里”(w3.org/QA/Tips/noClickHere>)。
-
谢谢大家,但我没有设计这个系统。我只是想解决它。
-
手动修复网址真的那么难吗?
-
@Gumbo:不,但不幸的是,这不是我的电话。