denoteone Posted February 22, 2010 Share Posted February 22, 2010 I need to update the img paths for all the images of my site. The current image tags are in the body variable in a database. I defined a base url with the define() function. $body = str_replace("<img src=\"'. constant(\"BASE_URL\") .'", "<img src=\"", $content[$counter]['body']); echo '<div class="article-teaser">'. $body .'</div>'; I am having issues. If anyone can help that would be great. I have a feeling it has something to do with the quotes. Thanks! Link to comment https://forums.phpfreaks.com/topic/192886-string-replace-to-add-a-defined-variable/ Share on other sites More sharing options...
ialsoagree Posted February 22, 2010 Share Posted February 22, 2010 I think more information is going to be needed to help you. Things need a bit more context. Right now, all that can be seen is that you're looking for a string that looks EXACTLY as I've typed it below: <img src="'. constant("BASE_URL") .' And you want to replace it with the following string exactly as I've typed it: <img src=" And you're searching in a string contained in $content[$counter]['body'] Without knowing what's in $content[$counter]['body'] or what's going wrong, there's no way to help you. Link to comment https://forums.phpfreaks.com/topic/192886-string-replace-to-add-a-defined-variable/#findComment-1015953 Share on other sites More sharing options...
denoteone Posted February 22, 2010 Author Share Posted February 22, 2010 @ialsoagree actually you have helped me more then you know. I have the find and replace backwards. Let me try that again. And I will send an update if I am still having issues. Link to comment https://forums.phpfreaks.com/topic/192886-string-replace-to-add-a-defined-variable/#findComment-1016088 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.