Kizzie33 Posted November 23, 2009 Share Posted November 23, 2009 I know you can do ereg_replace(); to find and replace a specific word but i wont to know if i can edit a segment if i dont know what the middle is. I dont know what the middle is but i know whats at the start a middle E.g. src="http://what.ever/goeshere" src=" and " will never change but whats in the middle will change is there a piece of code that will locate the src" and edit whats in the middle and stop at the next " ?? Thankyou ! And i hope i explained it in the least confusing way, im forever over complicating things Quote Link to comment Share on other sites More sharing options...
Alex Posted November 23, 2009 Share Posted November 23, 2009 First off, you shouldn't use the ereg functions, they're depreciated. Instead use the PCRE functions. In your case preg_replace. If you show us exactly what needs to be done we can help you with the pattern. Quote Link to comment Share on other sites More sharing options...
Kizzie33 Posted November 23, 2009 Author Share Posted November 23, 2009 I need to do what i put to be honest, im building a basic proxy server the I need to change all the herf's So it will be herf="/help/index.php" - for example Now herf=" will never change an it will always end with " And once i have the /help/index.php i wont to encrypt it with any basic encryption key which can then be decrypted later. Again sorry if i over complicated it Thankyou !! Quote Link to comment Share on other sites More sharing options...
Alex Posted November 23, 2009 Share Posted November 23, 2009 I'm gonna assume you mean href (because herf doesn't exist), do you mean something like this: $text = <<<TEXT <a href="/help/index.php">Something</a> Blah Blah Blah <a href="/help/something.php">Something</a> TEXT; $text = preg_replace('~href="([^"]+)~', "href=\"http://www.somesite.com$1", $text); echo $text; Output: <a href="http://www.somesite.com/help/index.php">Something</a> Blah Blah Blah <a href="http://www.somesite.com/help/something.php">Something</a> 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.