开发者

Help to write regex using php

I have a URL where I want to replace the equal to (=) next to &c and &app with %3d 开发者_运维知识库using php

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

I also want to remove the _8 from the $thumbnail

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


str_replace( array( '&c='   , '&app='   ), 
             array( '&c%3d' , '&app%3d' ), 
             $url
           );

Avoid regex when possible.


Try this regex

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜