0
当我想要preg_replace href,但只有它是我自己的时候,我该怎么办?preg_replace内部链接
$a = 'href="http://mysite.com/?s=Bananas&lang=en"';
$host = 'http://mysite.com';
$a = preg_replace('#href="'.$host.'\/?[(s|p)]=([.*?])&lang=([.*?])"#e','href="index.php#$1\/$2\\lang\/$3"',$a);
//The result I want:
echo $a;
//Becomes href="http://mysite.com/#s/Bananas\\lang/en"
但是我做错了什么? 此正则表达式的语法是非常困难的......
什么,你到底要不要?请写出你想要的输出。 – Chintan
This:'href =“http://mysite.com/#s/Bananas\\lang/en”' – maxxie
不要在你的正则表达式中使用'e'(PREG_REPLACE_EVAL)修饰符,除非你100%确定你是什么做... – binaryLV