Hi Dan,

maybe something like:

$newvariablethatwewantbetweenthetags = "Long variable!";

$string = preg_replace("/(<TAG>)(.*?)(<\/TAG>)/i",
\\1$newvariablethatwewantbetweenthetags\\2, $string));

There should be a " after and before the second part of that statement, but
my email proggy strips them.


"Dan Krumlauf" <[EMAIL PROTECTED]> wrote in message
> I've been trying this one for a bit and Im in a twist.
> I need to replace ANYTHING or even nothing between two tags
> with the contents of a variable and just havent been
> able to get the expression right for all cases.
> As an example concept follows:
> <TAG></TAG>
> Nothing between the tags variable is $varname="some junk"
> so after the function
> <TAG>some junk</TAG>
> run it again after making variable $varname="some completly different
> so now the tags would be
> <TAG>some completly different junk</TAG>
> and so on and so on.....
> One other breaker Ive had, it needs to always replace no matter whats
> between the tags, whats not between the tags or even if its 1000s of
> characters. My code kept breaking when it was alot of characters.
> Any funtions or even just the right regex would be appreciated
> Thanks

PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to