I need help with this ... I have a database with 3,000 records in it and every row includes a field with some text and urls inside it. The url and number of url's on every record varies... Heres an example of the code... some random text here <a href="http://www.some-url.com/randomtexthere.html?randomnumbers">random text here</a> <br><br> some random text here <a href="http://www.some-url.com/randomtexthere.html?randomnumbers">random text here</a><br> blah blah more text HTML: What i need to do.... is grab every url and change it to a variable (lets say $newurl) of my own. so the code should change to this; some random text here <a href="$newurl">random text here</a> <br><br> some random text here <a href="$newurl">random text here</a><br> blah blah more text HTML: From what i've read, the preg_replace function will do what i need, however i can't figure out how to write one of these "mixed patterns" for it to search for , can anyone give me a hand
Unless all the URLs end in something common, your best bet is to match the quotes and everything inside preg_replace('/\"http.*\"/','"$newurl"', $string_of_code); Code (markup):