Re: multi line string replace

From: Date: Thu, 23 May 2002 10:26:53 +0000
Subject: Re: multi line string replace
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-98858@lists.php.net to get a copy of this message
Kinda solved it. Basically wanted to do a mass replace on html stored in db. They are all the same. I Just got strpos of a page from the db. and used that string as $match. works fine. must be some character in there that means I cant match it. But then I would expect not being able to match just the <tr> So if i got the string from the DB it worked no problem. but if I tried making it myself no go. I was thinking newlines. then I thought the space after the "<tr> ". so i dont know. Oh yeah and I also tried matching both
$match2="        <tr>
              <td colspan=\"3\" valign=\"top\" class=\"footerline\">";
and $match2=<<<bs
      <tr>
              <td colspan="3" valign="top" class="footerline">
bs; but I could match : $match2=<<<bs
      <tr>
bs; $match2=<<<bs
              <td colspan="3" valign="top" class="footerline">
bs;
$match2="                <td colspan=\"3\" valign=\"top\" class=\"footerline\">";
$match2="        <tr> ";
$content I get from html stored in postgresql database echo str_replace($match,$replace,$content); also tried strstr, stristr etc etc. So I dont know. even when I tried \n instead of new lines. even runing nl2br on both strings to see if something wierd was going on. and <br>'s apeared in the same spots on both strings. Peter wrote:
can we have a looky at ur actual code for this? might help us to let you know where exactly the problem is with ur code... -----Original Message----- From: Aaron [ mailto:aarmel@netagi.com ] Sent: Thursday, 23 May 2002 7:41 PM To: php-general@lists.php.net Subject: [PHP] multi line string replace cant seem to get it to work say this is the string
"           <tr>
               <td colspan="3" valign="top" class="footerline">"
replace with "hello". problem is, i cant even get other functions to get the position of the string. No problems finding or matching replacing
"           <tr>"
or
"                <td colspan="3" valign="top" class="footerline">"
but together no luck. strstr, stristr etc str_replace. also tried
"           <tr>\n                 <td colspan="3" valign="top"
class="footerline">" also tried doing a nl2br on the compare string and actual string first to see if that'd work. replaced the exact same bits. -- PHP General Mailing List ( http://www.php.net/ ) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.general (#98858) next »