#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Posts
    10
    Rep Power
    0
    I'm having a hard time with this,

    I have a webpage in a variable and i'm trying to get just the part of the page i need.

    I'm very new with php but I know i need to split the variable into three parts

    example:

    trashtext1= first part of page right before <body.....>

    goodtext= text from rigth after body> to right before </body

    trashtxt2= all remaineing text

    then print goodtext

    I'm not sure how to do this. I've been trying all day...

    Thanks
    david
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 1999
    Posts
    15
    Rep Power
    0
    read the file into an array:
    $arr=file("file.html");

    make a string from the array:
    $str="";
    for($i=0;$i<sizeof($arr);$i++){
    $str=$str.$arr[$i];
    }

    .. then use regular expressions on
    $str http://www.phpbuilder.com/columns/dario19990616.php3
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 1999
    Location
    Annapolis, Maryland US
    Posts
    113
    Rep Power
    15
    Try this as a test....

    <?
    $var="<html><head></head><body>This is the main document text</body></html>";


    $sections=split("<[/]?body>", $var, 3);


    print"The first index is $sections[0]<br>";
    print"The second index is $sections[1]<br>";
    print"The third index is $sections[2]<br>";


    ?>

    [This message has been edited by Kyuzo (edited January 13, 2000).]
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Posts
    10
    Rep Power
    0
    Thanks Kyuzo

    It works great!

Similar Threads

  1. Cutting down on CPU/Processing time
    By ArmedCoder in forum C Programming
    Replies: 8
    Last Post: February 28th, 2004, 12:41 AM
  2. email and junk mail
    By Andrew_Smart in forum PHP Development
    Replies: 1
    Last Post: November 28th, 2003, 02:03 PM
  3. Xml Parsing Problems-->>xml Strings Randomly Cutting Off!
    By CLEM_C_ROCK in forum PHP Development
    Replies: 0
    Last Post: September 5th, 2003, 01:20 PM
  4. making free money (not a junk mail post)
    By dsm56 in forum Dev Shed Lounge
    Replies: 22
    Last Post: January 11th, 2002, 07:15 AM
  5. Cutting off populated form fields!!
    By akpcep in forum PHP Development
    Replies: 15
    Last Post: January 3rd, 2002, 07:26 AM

IMN logo majestic logo threadwatch logo seochat tools logo