Regular expression - php replace url?
PHP中文网
PHP中文网 2017-05-16 12:02:43
0
3
725

Before replacement:
http://www.163.com/cc/content before replacement/

After replacement
http://www.163.com/cc/content after replacement/

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(3)
phpcn_u1582

$str="http://www.163.com/cc/content before replacement/";
$preg = "/cc/(.+)//";
$after = preg_replace($preg, "To Replacement content", $str);

仅有的幸福
$subject = preg_replace('//替换前内容\//', '/替换后内容/', 'http://www.163.com/cc/替换前内容/');
var_dump($subject);
漂亮男人
$url = preg_replace('/替换前内容/', '替换后内容', 'http://www.163.com/cc/替换前内容/');
或者
$url = preg_replace('#替换前内容#', '替换后内容', 'http://www.163.com/cc/替换前内容/');
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template