我想这个URI来替换这个URIPHP正则表达式的preg_replace
http://localhost/prixou/index.php?page=list&category=1&sub=1&subsub=0&brand=Sony&toto=titi
http://localhost/prixou/index.php?page=list&category=1&sub=1&subsub=0&kljklj=sdfsd
==>我要删除 “&品牌=索尼”
我尝试这样做:
preg_replace('/(^.*)(&brand=.*)(&.*)/', '$1$3', 'http://localhost/prixou/index.php?page=list&category=1&sub=1&subsub=0&brand=Sony&toto=titi');
bu t将其不特定的情况下工作:的情况下在URI参数“TOTO”不存在
所以,如果我做
preg_replace('/(^.*)(&brand=.*)(&.*)/', '$1$3', 'http://localhost/prixou/index.php?page=list&category=1&sub=1&subsub=0&brand=Sony');
它不工作==>“ &品牌=索尼“仍然出现
那么我该怎么办?
你没有指定'preg_replace'到任何结果,因此它被执行后基本丧失。 – 2013-03-21 17:29:29