SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to get just part of code ?!

    Hi ..


    I have file start with :

    <!-- message -->

    and ends with

    <!-- / message -->

    How to make ereg to get the content just in this tags !!


    thx in advance.

  2. #2
    SitePoint Addict phptek's Avatar
    Join Date
    Jun 2002
    Location
    Wellington, NZ
    Posts
    363
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $url "myfile.html";
      
      
    $START_CONT "<!-- message -->";
      
    $END_CONT "<!-- / message -->";
      
      
    $f_contents file(urldecode($url));
      
    $body "";
      foreach(
    $f_contents as $line)
      {
          if(
    ereg($START_CONT,$line))
          {
              
    $content=1;
          }
          if(
    ereg($END_CONT,$line))
          {
              
    $content=0;
          }
          if(
    $content==1)
          {
              
    $body .= $line;
          }
      } 
    The value of the $line variable is what appears between your <!-- message --> tags


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •