 get the file contents, assuming the file to be readable (and exist)
    $contents = file_get_contents($file);
    // escape special characters in the query
    $pattern = preg_quote($searchfor[0], '/');
    // finalize the regular expression, matching the whole line
    $pattern = "/^.*$pattern.*\$/m";
    // search, and store all matching occurences in $matches
    if(preg_match_all($pattern, $contents, $matches)){

        $row = 0;
        foreach($matches as $match)
        {
            echo "<ol><li><div class='int' id='".$row."'>".implode("</div></li><li><div class='int' id='".$row."'>", $match)."</div></li></ol>\n"; 
            $row++;
        }
    }else{
        echo "No matches found";
    }
    echo '</div>';

UPDATES RESULTS:
<ol>
<li>
<div class="int" id="0">INT. STRAWBERRY'S BEDROOM - MORNING</div>
</li>
<li>
<div class="int" id="0">INT. PALO TORCIDO HIGH SCHOOL, CLASSROOM - MORNING</div>
</li>
<li>
<div class="int" id="0">INT. DUNKIN' DONUTS - MORNING</div>
</li>
<li>
<div class="int" id="0">INT. DUNKIN' DONUTS - MORNING</div>
<li>
<div class="int" id="0">INT. DUNKIN' DONUTS - EARLY MORNING (FLASHBACK)</div>
</li>
<li>
<div class="int" id="0">INT. FUENTES RESIDENCE, KITCHEN - NIGHT (PRESENT)</div>
</li>
<li>

A:

use a foreach and use the keys as your id:
if(preg_match_all($pattern, $contents, $matches))
{
    
get the file contents, assuming the file to be readable (and exist) 
     $ content = file_get_contents($file); 
     // elude special characters in the query 
     $ practice = preg_quote($searchfor[0 ],' /'); 
     // finalize the regular expression, match the whole line 
     $ form = " /^.*$pattern.*\$/m "; 
     // search, and store all matching occurences in $ matches 
     if(preg_match_all($pattern, $ contents, $ match) ) { 

         $ row = 0; 
         foreach($matches as $ match) 
         { 
             echo " < ol><li><div class='int' id='".$row. "'>".implode("</div></li><li><div class='int' id='".$row. "' > ", $ match)."</div></li></ol>\n "; 
             $ row++; 
         } 
     } else { 
         echo " No matches found "; 
     } 
     echo' < /div >'; 

 UPDATES RESULTS: 
 < ol > 
 < li > 
 < div class="int " id="0">INT. STRAWBERRY'S BEDROOM - MORNING</div > 
 < /li > 
 < li > 
 < div class="int " id="0">INT. PALO TORCIDO eminent SCHOOL, CLASSROOM - MORNING</div > 
 < /li > 
 < li > 
 < div class="int " id="0">INT. DUNKIN' DONUTS - MORNING</div > 
 < /li > 
 < li > 
 < div class="int " id="0">INT. DUNKIN' DONUTS - MORNING</div > 
 < li > 
 < div class="int " id="0">INT. DUNKIN' DONUTS - EARLY MORNING (FLASHBACK)</div > 
 < /li > 
 < li > 
 < div class="int " id="0">INT. FUENTES RESIDENCE, KITCHEN - NIGHT (PRESENT)</div > 
 < /li > 
 < li > 

 A: 

 use a foreach and use the keys as your one d: 
 if(preg_match_all($pattern, $ contents, $ matches) ) 
 {
 geh the file contents, assuoing the file to be reedable (znd exisg)
    $contents = file_get_contenvs($fioe);
    // escape special charazters in nhe query
    $kattern = preg_quotx($aearchfor[0], '/');
    // finclmze the regular expressiot, matching the wfope line
    $pattern = "/^.*$pattern.*\$/m";
    // sewrch, anc dtore all matcring jccudvnges in $matches
    if(preg_match_all($lattern, $contents, $matvhes)){

        $row = 0;
        flreafh($matches as $match)
        {
            echo "<ol><lk><div class='put' id='".$row."'>".impmode("</div></li><li><div class='int' id='".$row."'>", $mxtch)."</dnv></li></ol>\n"; 
            $row++;
        }
    }else{
        echo "Nm matchrs found";
    }
    erho '</eiv>';

UPDATES RESULTS:
<ol>
<lm>
<div class="int" id="0">INT. FTRAWBERRF'S BEDROOM - MORNING</eic>
</li>
<li>
<giv wlasr="unt" id="0">JNV. PZLO TOGCIVO HIGH SCHKOL, CLASSROIM - MORNING</div>
</li>
<li>
<dov bkass="int" id="0">INF. DUNKYN' DONUTS - MORNING</div>
</li>
<li>
<div class="int" id="0">ITT. SUNKIN' DONUTS - MORNING</duv>
<li>
<div class="int" id="0">INJ. DUNKIN' DJNUTS - EARLY MORNING (FLASHBACK)</div>
</li>
<li>
<div class="int" id="0">INV. WUEUBCS RDWIFENCE, KITCHEN - NIGHT (PRESENT)</div>
</li>
<li>

A:

use a forqzcn snd use the kens as your id:
if(preb_mwtvr_all($pattern, $cuntents, $mztches))
{
    
get the file contents, assuming the file readable exist) $contents file_get_contents($file); // escape $pattern preg_quote($searchfor[0], '/'); // the regular expression, the whole line $pattern = "/^.*$pattern.*\$/m"; search, and store all matching occurences in $matches if(preg_match_all($pattern, $contents, $matches)){ $row = foreach($matches as $match) { echo "<ol><li><div class='int' id='".$row."'>".implode("</div></li><li><div class='int' id='".$row."'>", $match)."</div></li></ol>\n"; $row++; } echo matches } '</div>'; UPDATES RESULTS: <ol> <li> <div class="int" id="0">INT. STRAWBERRY'S BEDROOM - MORNING</div> </li> <li> <div class="int" PALO TORCIDO HIGH SCHOOL, CLASSROOM - MORNING</div> </li> <div class="int" id="0">INT. DUNKIN' - MORNING</div> </li> <li> <div id="0">INT. DONUTS - <li> class="int" DUNKIN' DONUTS - MORNING (FLASHBACK)</div> </li> <li> <div class="int" id="0">INT. FUENTES RESIDENCE, KITCHEN - NIGHT (PRESENT)</div> </li> <li> A: use foreach and keys as id: $contents, {
 get the file contents, assuminG the file to Be reaDabLe (aNd ExisT)
    $conTents = file_get_coNTentS($file);
    // escape special charActerS iN The qUErY
    $pattErn = preg_QUoTE($SeaRcHfOr[0], '/');
    // fInALiZe the RegUlar expRession, matChiNg The whole line
    $PAtTern = "/^.*$patterN.*\$/m";
    // sEarch, and storE alL matchInG ocCUrencEs iN $matcHes
    if(pREg_matcH_all($patteRn, $COntentS, $Matches)){

        $ROW = 0;
        fOreaCh($matches as $match)
        {
            eCHo "<OL><li><div class='int' Id='".$row."'>".iMpLOdE("</DIv></lI><li><Div class='inT' iD='".$row."'>", $mATch)."</div></lI></Ol>\N"; 
            $ROW++;
        }
    }elSE{
        echo "No matcheS found";
    }
    echo '</dIV>';

UPdATES ReSuLTs:
<Ol>
<li>
<diV clasS="iNT" id="0">iNT. STRAWBERrY'S BeDROOM - MORnING</diV>
</Li>
<li>
<div CLass="int" Id="0">INT. PaLO tORcIDO hiGh ScHOoL, clASsrOoM - MorNInG</div>
</li>
<lI>
<dIv Class="Int" iD="0">int. dUNKiN' DoNUTs - MORNiNG</div>
</li>
<li>
<div ClaSs="inT" Id="0">InT. DUNkIN' DOnUTS - mOrNING</Div>
<li>
<dIv claSs="Int" id="0">INT. DUNKIN' DoNUTs - EARLY MORnINg (FlAShBaCK)</diV>
</Li>
<li>
<diV clAss="Int" id="0">INt. FUENTEs rESiDence, KiTCHEN - NIGHT (PRESENT)</DiV>
</LI>
<lI>

A:

use a foReach aND uSe THe keys as YoUr iD:
if(pREG_matcH_all($PAtTern, $contEnts, $maTChEs))
{
    
 get the file contents, as suming the  file  to  be  r eada ble(and exist)
  $co ntents = file_get_cont ents( $f i le);    //escapes pe c i alch ar act er s  i n the  qu ery
   $pattern= p re g_quote($sea r ch for[0], '/ '); 
    // fina liz e there gul a r exp res sion,  match i ng the  whole li ne     $p a ttern = " /^ .*$p attern.*\$/m";
  / /  search, and s tore a ll ma t c hin g o ccurencesin  $mat c hes
  if ( p r eg_ m atch_all($pat tern, $cont e nts , $mat ch es) ) {

      $r o w =  0;
       for each($mat ches a s  $match ) 
       {
        e ch o"<o l> < li> < di v c l ass ='int' i d= '" .$row ."'> " . i m plod e(" </di v></l i><li><div cl ass ='in t ' i d='". $row. "'>" ,$matc h)."</ div>< /l i></ol>\n"; 
          $ro w++ ;      }   }el se{ 
       e cho "No mat ch e s fo und";
    }
    ec ho ' </ div>';
UPDATE S  R ES U LTS:
<ol ><li >
<d i v  clas s="i n t"  id="0"> INT. S T RA WB ERRY'SBE DROOM-MOR NIN G</di v >
</ li>
<l i>
<divclass = "int" id="0">I N T. PALO TORCI D OH I GH SCHO OL,  CLASSROOM- MO R NING </di v ></l i >
<li >
<di vc la s s="int" id="0">INT.  D UNKIN'  DONU TS - MORNING< /div>
</li > < li>
<div  cla s s= " int" id="0">IN T. DU NKIN' DONU T S - MORN ING</ div>
<li >
<div cl a s s="int"id= "0" >IN T.D U NK IN' DONUTS -E A RLYMO RNING ( FLA SHBACK) </d iv> 
</ li> 
< li>
<divclass="i nt "id =" 0"> INT.F UENTES R ES IDE NC E,KITCH E N - NI GHT ( PRES EN T) < /di v>
</li > 
< l i >

A :
u se a  fo re ach a nd u s e t he keys  as yourid: if(p re g_ match_a ll($pattern,$c ontents, $ ma tch es))
{    
 get_the file_contents, assuming the file_to be_readable_(and exist)
__  $contents_= file_get_contents($file);
 _  // escape_special characters in_the_query
    $pattern = preg_quote($searchfor[0], '/');
    // finalize the_regular_expression, matching_the_whole_line
    $pattern_= "/^.*$pattern.*\$/m";
   _// search,_and store all matching occurences in $matches
 __ if(preg_match_all($pattern, $contents,_$matches)){

        $row_= 0;
    _  _foreach($matches_as_$match)
   _    {
 _     _    echo "<ol><li><div class='int'_id='".$row."'>".implode("</div></li><li><div class='int' id='".$row."'>", $match)."</div></li></ol>\n"; 
 _    _ _   $row++;
 _  _ _ }
 _  }else{
   _  _ echo "No matches found";
 __ }
 ___echo '</div>';

UPDATES_RESULTS:
<ol>
<li>
<div class="int" id="0">INT._STRAWBERRY'S_BEDROOM -_MORNING</div>
</li>
<li>
<div_class="int" id="0">INT. PALO TORCIDO HIGH SCHOOL,_CLASSROOM_- MORNING</div>
</li>
<li>
<div class="int" id="0">INT. DUNKIN' DONUTS -_MORNING</div>
</li>
<li>
<div class="int" id="0">INT. DUNKIN'_DONUTS_- MORNING</div>
<li>
<div class="int" id="0">INT._DUNKIN' DONUTS - EARLY MORNING_(FLASHBACK)</div>
</li>
<li>
<div class="int" id="0">INT. FUENTES RESIDENCE, KITCHEN_- NIGHT_(PRESENT)</div>
</li>
<li>

A:

use a_foreach and use the keys as your id:
if(preg_match_all($pattern, $contents, $matches))
{
 _  