使用php编写正则表达式的帮助

使用php编写正则表达式的帮助,php,regex,preg-replace,preg-match,Php,Regex,Preg Replace,Preg Match,我有一个URL,希望使用php将&c和&app旁边的等于(=)替换为%3d $ddd_url = '<asset ="http://www.ggtt.com/dfghdzHV8?f=videos&c=AIfgdfdfVQQ93m-ikEn0N3FqIfgdf45tdgdsHuwtysV-I8SEdfsgdf44xmNPW_B-kX33bw&app=dde_gdata"/>'; $ddd_url=''; 我还想从$thumbnail中删除_8 $thumbnail=

我有一个URL,希望使用php将&c和&app旁边的等于(=)替换为%3d

$ddd_url = '<asset ="http://www.ggtt.com/dfghdzHV8?f=videos&c=AIfgdfdfVQQ93m-ikEn0N3FqIfgdf45tdgdsHuwtysV-I8SEdfsgdf44xmNPW_B-kX33bw&app=dde_gdata"/>';
$ddd_url='';

我还想从$thumbnail中删除_8

$thumbnail=”http://d2dsfsd.humbnails/20415/33-d148-45b1-9098-11e5c/thumbnail_8.jpg";

尽可能避免使用正则表达式

尽可能避免使用正则表达式。

试试这个正则表达式

$result = preg_replace('/(&c|&app)(=)/i', '$1%3d', $ddd_url);
试试这个正则表达式

$result = preg_replace('/(&c|&app)(=)/i', '$1%3d', $ddd_url);

您是希望替换“=”字符,还是希望对整个内容进行URL编码?我有一种感觉,你想要后者——你只是想替换“=”字符,还是想对整个东西进行URL编码?我感觉你想要后者——我还想从$thumbnail$thumbnail=”“中删除“8”;打开另一个问题。这不是聊天室,我还想从$thumbnail$thumbnail=“”中删除“u8”;打开另一个问题。这不是聊天