0
我有一个HTML代码放在一个变量。我想用str_replace替换任何相对的图像src到绝对的aby。像这样:php str_replace不工作
$export = 'some html codes'
$repthis = 'src="/images';
$reptothis = 'src="http://images.site.com';
$export = str_replace($repthis, $reptothis, $export);
但这段代码不适用于我。我想测试此代码,它工作:
$export = 'some html codes'
$repthis = "text1";
$reptothis = "text2";
$export = str_replace($repthis, $reptothis, $export);
这段代码是在我的HTML代码正确更换的text1的文本2。 请帮助我。
的代码看起来是正确的。仔细检查你的模式。你的原始文本中是否有'src =“/ images'? – WebNovice