변수에 put 된 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을 text2로 올바르게 대체합니다. 도와주세요.
코드는 올바른 보인다. 패턴을 다시 확인하십시오. 원본 텍스트에 정확히'src = "/ images'가 있습니까? – WebNovice