mark_nsx Posted August 6, 2008 Share Posted August 6, 2008 hi guys i need your help. basically i need to grab all image tags and modify its source by replacing multiple "../../../" with two "../../" eg. <img src="../../ .." /> cheers! Quote Link to comment Share on other sites More sharing options...
secoxxx Posted August 6, 2008 Share Posted August 6, 2008 What are you using to edit your code? Quote Link to comment Share on other sites More sharing options...
mark_nsx Posted August 6, 2008 Author Share Posted August 6, 2008 dreamweaver hehe. Quote Link to comment Share on other sites More sharing options...
secoxxx Posted August 6, 2008 Share Posted August 6, 2008 Edit > Find and Replace in the find box do ../../../ or <img src="../../../ in the replace box do ../../ or <img src="../../ then hit the Find next button, when you come across the imag tags src ones hit replace, then find next again, this is just incase you have others with ../../../ you want to keep. if not, Replace all. Quote Link to comment Share on other sites More sharing options...
mark_nsx Posted August 6, 2008 Author Share Posted August 6, 2008 sorry my description wasn't clear..i have to implement this in php for my dynamic code.. Quote Link to comment Share on other sites More sharing options...
secoxxx Posted August 6, 2008 Share Posted August 6, 2008 is the ../../../ in the database or somthing? Quote Link to comment Share on other sites More sharing options...
mark_nsx Posted August 6, 2008 Author Share Posted August 6, 2008 its the output of tinyMCE editor. for some reason it changes the source of the images inserted to it when i submit the form. Quote Link to comment Share on other sites More sharing options...
secoxxx Posted August 6, 2008 Share Posted August 6, 2008 hmm, maybe try a different wysiwyg editor and see if that fixes it. Quote Link to comment Share on other sites More sharing options...
discomatt Posted August 7, 2008 Share Posted August 7, 2008 You could use regex. $subject = preg_replace( '%(?:\\.\\./){3,}+%', '../../', $subject ); Will replace 3 or more '../' with '../../' Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.