#1
  1. cave painting, the 1st Opn Src
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2003
    Posts
    532
    Rep Power
    0

    Php exp to remove section of code


    I'm looking for the php equilant of
    Code:
    sed '/< a id=3>/,/< a id=4>/d'
    to remove this section from my file. I've used strpos to strip parts of the top and bottom, but can it also remove from the middle of the document? if so, how?

    Code:
    // 1st Pass to remove Header Info
    $Marker2 =strpos($fileData1, "\n", strpos($fileData1, "< a id=1>")) ;
    $Marker3 =strlen($fileData1); 						
    $fileData2 = substr($fileData1,$Marker2,$Marker3);
    I could cut the top and bottom areas of the page and concatenate them back together, but I was hoping for a more graceful answer.
    Curious by Nature,
    Linux by Choice
    Lawson ERP reference tools: Lawsuss.com
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,066
    Rep Power
    9398
    If you're just deleting that section,
    PHP Code:
    $id3 strpos($string"< a id=3>");
    $id4 strpos($string"< a id=4>"$id3);
    $string substr($string0$id3) . substr($string$id4); 
  4. #3
  5. cave painting, the 1st Opn Src
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2003
    Posts
    532
    Rep Power
    0
    Originally Posted by requinix
    If you're just deleting that section,
    PHP Code:
    $id3 strpos($string"< a id=3>");
    $id4 strpos($string"< a id=4>"$id3);
    $string substr($string0$id3) . substr($string$id4); 
    thanks for this! It worked great
    Curious by Nature,
    Linux by Choice
    Lawson ERP reference tools: Lawsuss.com

IMN logo majestic logo threadwatch logo seochat tools logo