Jump to content

getting characters out of an html code stored in variable..


MidOhioIT

Recommended Posts

The issue..

We are developing an html newsletter.  The client is creating an entire Html page as shown below.  A requirement for the newsletter is to provide an opt out list link at the bottom of the newsletter when it goes out.  We provided a form with text area where they put in this html code and we capture it in a variable and then just make it the body of the newsletter email.  The issue is since they are ending their html code the proper way: </body> </html> I can not just append any links to the end of it i dont believe.  I was tring to find a way to just replace the end tags with "" and would append what i needed and then just add them back in.  I cant do that becasue they are doing more instances of </html> tags then just the last one.  is there a way to just strip it off the end?  here is the full html code that is being sent through the form:

 

<html>
<head>
<title>Spring Getaways</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
</html>
<html>
<head>
</head>

<body bgcolor="#FCFBE2" link="#000099" vlink="#3366CC" background-repeat: repeat-x;>
<table width="600" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000" bgcolor="#FFFFFF">
  <tr>
    <td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align="left" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
          <tr>
            <td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="left" valign="top"><img src="../graphics/e_heading_spring10.jpg" alt="Spring Specials email header graphic" width="620" height="157"></td>
              </tr>
              
            </table>              </td>
          </tr>
          
          
          
          
        </table>        </td>
      </tr>
      
      
      
    </table>      </td>
  </tr>
  <tr>
    <td align="left" valign="top"><table width="100%" align="center" cellpadding="8" bgcolor="#FFFFFF">
      <tr>
        <td height="50" colspan="3" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="8">
          <tr>
            <td colspan="2" align="left" valign="top"><table width="175" border="0" align="right" cellpadding="0" cellspacing="0">
              <tr>
                <td> </td>
                <td width="150"><font color="#000000" size="3" face="Verdana, Arial, Helvetica, sans-serif"><strong><img src="../graphics/family_cutout.jpg" alt="Photo of a family in front of the lodge" width="150" height="132" border="1" align="right"></strong></font></td>
              </tr>
            </table>
              <p><font color="#000000" size="3" face="Verdana, Arial, Helvetica, sans-serif"><strong>Spring Getaways at Resort</strong></font><br>                  
                <font size="1" face="Verdana, Arial, Helvetica, sans-serif">Enjoy overnight accommodations at the 271-room <a href="http://www.website.com/lodge.htm">Wilson Lodge</a></font> </p>
              <table width="50" border="0" align="left" cellpadding="0" cellspacing="0">
                <tr>
                  <td width="20"><a href="http://www.facebook.com/Resortresort" target="_blank"><img src="http://www.website.com/graphics/facebook_16.png" alt="Link to Facebook page" width="16" height="16" border="0" align="left"></a></td>
                  <td width="20"><a href="http://twitter.com/ResortResort" target="_blank"><img src="http://www.website.com/graphics/twitter_16.png" alt="Link to Twitter page." width="16" height="16" border="0" align="left"></a></td>
                </tr>
              </table>
              <p><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong><font size="2">NEW! Socialize with Us! </font></strong></font><br>
                <font size="1" face="Verdana, Arial, Helvetica, sans-serif">Make sure to stay  connected with all that is happening at Resort. Join our communities on  Facebook and Twitter for regular updates and upcoming specials and become part  of the tradition that makes Resort Resort and Conference Center so special. </font></p>              </td>
            </tr>
          
          
        </table>
          <hr align="left" size="1" noshade></td>
      </tr>
      <tr>
        
      </tr>
      
      <tr>
        <td colspan="3" align="left" valign="top"></td>
      </tr>
      
      <tr>
        <td colspan="3" align="left" valign="top"><table width="100%" border="1" cellpadding="3" cellspacing="0" bordercolor="#000000" bgcolor="#FFFFFF">
            <tr>
              <td bgcolor="#7165AD"><FONT color="#FFFFFF" SIZE="3" face="Verdana, Arial, Helvetica, sans-serif" class="large_white_text"><B>Spring Alive </B><font color="#EAF3C5" size="2"><strong>A beautiful, relaxing time for a getaway!</strong></font></FONT></td>
            </tr>
            <tr>
              <td align="left" valign="top" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="105" align="left" valign="middle"><img src="http://www.website.com/graphics/icon_spring.jpg" alt="Spring Alive Package icon" width="90" height="90" border="1" align="left" class="body_copy"></td>
                    <td align="left" valign="middle"><table width="100%" border="0" align="left" cellpadding="0" cellspacing="0">
                        <tr>
                          <td colspan="2" align="left" valign="middle"><b class="large_black_text"><font size="3" face="Verdana, Arial, Helvetica, sans-serif"><strong><font size="3" face="Verdana, Arial, Helvetica, sans-serif"><a href="http://www.website.com/smsworld/wc.dll?smsworld~availbox" target="_blank"></a></font></strong><a href="https://reservation.website.com/V1WebControls/ResvDates.aspx" target="_blank"><img src="http://www.website.com/graphics/book_now_purple.jpg" alt="Link to reservations page" width="79" height="65" border="0" align="right"></a><strong><font size="3" face="Verdana, Arial, Helvetica, sans-serif">Starting at $145*</font></strong></font></b><font face="Verdana, Arial, Helvetica, sans-serif"><br>
                                <strong><font size="2">Weekdays (Sun-Thurs)<br>
                                  Available April 3 - May 21, 2009 Only</font></strong><br>
                            <em><font size="1">Excluding holidays & special weekends <br>
                              * Double Occupancy. Plus tax. Per Night Package Code: SPFL</font></em></span></font></td>
                        </tr>
                    </table></td>
                  </tr>
              </table></td>
            </tr>
            <tr>
              <td bgcolor="#ADA6D0"><table width="200" border="0" cellspacing="0" cellpadding="2">
                  <tr>
                    <td><strong><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">Package includes:</font></strong></td>
                  </tr>
              </table></td>
            </tr>
            <tr>
              <td align="left" valign="middle" bgcolor="#F1F8DA"><table width="100%" border="0" cellspacing="0">
                  <tr>
                    <td><table width="100%" border="0" cellspacing="0" cellpadding="3">
                        <tr>
                          <td width="2%" align="left" valign="top" class="body_copy"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">•</font></td>
                          <td width="98%" align="left" valign="top" class="body_copy"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Overnight Accommodations at Wilson Lodge </font></td>
                        </tr>
                        <tr>
                          <td align="left" valign="top" class="body_copy"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">•</font></td>
                          <td align="left" valign="top" class="body_copy"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Mountaineer Buffet Breakfast</font></td>
                        </tr>
                        <tr>
                          <td align="left" valign="top" class="body_copy"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">•</font></td>
                          <td align="left" valign="top" class="body_copy"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Unlimited Use of Indoor Pool, Jacuzzi 
                            
                            & Fitness Center</font></td>
                        </tr>
                    </table></td>
                  </tr>
              </table></td>
            </tr>
            <tr>

            </tr>
          </table></td>
      </tr>
      

      
      <tr>
        
      </tr>
      <tr>
        <td colspan="3" align="left" valign="top"><table width="100%" border="1" cellpadding="5" cellspacing="0" bordercolor="#000000" bgcolor="#CC6633">
            <tr>
              <td bgcolor="#E4F7A8"><p align="center"><strong><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif">Many other packages  available! Call 800-624-6988 or visit our <a href="http://www.website.com" target="_blank">web site</a>.</font> </strong></p>
                <p><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">1,700-acre Resort features: </font></strong><font size="1" face="Verdana, Arial, Helvetica, sans-serif">271-room Wilson Lodge,  Casual & Fine Dining, Spa, 54 Cottages, Ski & Snowboard Area, 72 Holes of Golf, Specialty Shops, Gardens, Good Zoo & Benedum Planetarium, Mansion Museum, Glass Museum, Indoor & Outdoor Pools, Tennis, Fishing, Stables, Miniature Golf, Environmental Center, Pedal Boating and a Resort Shuttle.</font></p></td>
            </tr>
        </table></td>
      </tr>
      <tr>
        <td height="20" colspan="3" align="left" valign="top"><div align="center"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Keep Resort e-mails coming! Add marketing@website.com to your address book now. If you are unable to view this message go to <a href="http://www.website.com/emails/spring_getaway0310.html"><font color="#006600">http://www.website.com/emails/spring_getaway0310.html</font></a>. </font></div></td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>

Link to comment
Share on other sites

I dont think this is helping...

1) all i need to do looking at the html is strip the final tags: </body></html>

2) and then put some links in like  <a href="http://www.website.com>Click here</a>

3) Put the tags back so now the links are in the body:

 

<a href="http://www.website.com>Click here</a>

</body>

</html>

 

Here is how the code is getting the html from the text area now...:

$newsletter_body = $_SESSION["newsletter_body"];

 

inside the variable newsletter_body is the entire html code i posted, so now i need to strip only the last 2 tags so i can put my links in it and then put them back.  I hope this makes sence.

Link to comment
Share on other sites

Yes it does what you want.

it takes the link and puts the close body tag after it. It then replaces the close body tag in the body with the link/tag combo. You will of course have to substitute $newsletter_body for the $body I show then use the $new_body(or what ever you want to rename it to) in the newsletter.

 

 

HTH

Teamatomic

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.