我确实遇到了问题,在我选择的情况下 来自MYSQL数据库的信息保存到$ data。
我有2个preg_replace数组。
这是一个例子:
$repl();
$repl[0] = '/bull/';
$repl[1] = '/found/';
$repl[2] = '/search/';
$replto();
$replto[0] = 'This is not a ballon';
$replto[1] = 'This has been found';
$replto[2] = 'Im looking for it';
$data = array();
$data[0] = '/mynickname/search';
$data[1] = '/somebulls/search';
$data[2] = '/mcdo/found';
$data[3] = '/bump/search';
$data[4] = '/blood/bull';
echo preg_replace($repl,$replto,$data);
好的,但是preg_replace的输出是这样的:
/mynickname/Im looking for it
/somebulls/Im looking for it
/mcdo/This has been found
/bump/Im looking for it
/blood/This is not a ballon
...但我想要这个输出:
Im looking for it
Im looking for it
This has been found
Im looking for it
This is not a ballon
我是php的新手,我解决了很多问题,但这是一个我没有找到解决方案的问题。
你能帮我吗?
答案 0 :(得分:1)
非常感谢它的完美运作。
像是
$repl();
$repl[0] = '/.*bull/';
$repl[1] = '/.*found/';
$repl[2] = '/.*search/';
对于迟到的回答感到抱歉,不能早点到来。
再次非常感谢。
答案 1 :(得分:0)
根据您想要的结果,您似乎想要执行以下操作:
$repl();
$repl[0] = '/.*bull/';
$repl[1] = '/.*found/';
$repl[2] = '/.*search/';