Customizeing a Search engine. Need help with string

This is the whole patch of code im trying to rewrite for my website.

  //collect links and generate cache files
  function cacheFiles() {
    if ($this->error) return false;
    $mylinks = array();
    $mycontent = @file_get_contents($this->url);
    $mylinks = $this->get_href($mycontent);
    //expanding with the incl array
    if ($this->incl) $mylinks = array_merge($mylinks,$this->incl);
    $this->collectUrls($mylinks, $this->url);
    $this->checkedUrls = array_values(array_unique($this->checkedUrls));
    $cnturls = count($this->collectedUrls);   
    $y = 0; 
    for ($i=0;$i<$cnturls;$i++) {
      $mycontent = @file_get_contents($this->collectedUrls[$i]);
      if ($mycontent) {
        //find page title
        preg_match_all("/<title(.*)>(.*)<\\/title>/i", $mycontent,$tarr);
        $title = $tarr[2][0];
        //cut till body if body :)
        if (stristr($mycontent,"<!--DIE NOT MODIFY -->")) $body = substr($mycontent,stripos($mycontent,'<!--die'));
        else $body = $mycontent;
        $body = $this->br2nl($body);
        $body = strip_tags($body);
        $body = preg_replace('/\
/', " ", $body);
        $body = preg_replace('/\\s{2,}/', " ", $body);
        $cache_data .= '$cache_data[' . $y . '] = array("url" => "' . addslashes($this->collectedUrls[$i]) . '",
          "title" => "' . addslashes($title) . '");' . "\
    if ($cache_data) $this->write("data.php",'<?php' . "\

The Part im having trouble with is this.
if (stristr($mycontent,“<!–DIE NOT MODIFY –>”)) $body = substr($mycontent,stripos($mycontent,‘<!–die’));

I modified this part so that when in my pages when it see’s <!–DIE NOT MODIFY –> This is where it Begins Reading whats on the page, caches all the text into a text file and adds it to the search engine.

How do i add something like


To The end of the content section so that the search process/cache process Stops at that tag.

So instead of starting at <!–DIE NOT MODIFY –> then copying all text from then to the bottom to do this instead

Copy text past <!–DIE NOT MODIFY –> and stop copying at <!–//DIE NOT MODIFY –>

Try this,

 if( preg_match_all("#<!--\\s*DIE NOT MODIFY\\s*-->(.*)<!--//DIE NOT MODIFY\\s*-->#i", $mycontent,$match); ) 

In place of this,

 if (stristr($mycontent,"<!--DIE NOT MODIFY -->"))

I haven’t tested it so you might need to modify the regex.
print_r($match) will show you any matches found. If found you can remove it and put
$body = match[1];

Also wanted to note that I am not a ajax/php expert at all, I did spend a entire day Googling and looking on php sites for a solution but i could not figure it out.