title: error in php programming
body: <p>I have a text file write.txt:-<strong>write.txt</strong></p>
  
  <pre><code>My name
  
  jai hind
  
  stack
  </code></pre>
  
  <p>I am getting the error in the following code at line 154 and 165 and the error is:-</p>
  
  <blockquote>
    <p>PHP Notice:  Uninitialized string offset: 11 in /home/sakshi/Desktop/syllabify/step2/Syll_script_1.php on line 154</p>
  </blockquote>
  
  <p>PHP Notice:  Undefined offset: -2 in /home/sakshi/Desktop/syllabify/step2/Syll_script_1.php on line 165</p>
  
  <p><strong>code:-</strong></p>
  
  <pre><code>$file1 = fopen("write.txt", "r");
  
  $q=1;
  while ( $line = fgets($file1) )
  {
  
      $i=0;
      $arr = explode( "\n", $line );
      $q=$q+1;
      if(strcmp($arr[0],"." ) == 0)
      {
          $i=1;
          $q=$q-1;
          echo "\nposition of dot in write.txt:";
          echo "$i \t $q\n";
          break;
      }
  }
  fclose($file1);
  
  if($i==0)
      echo $i;
  
  while ( $q!=1 )
  {
  
      $file_input=fopen("input.txt","r");
      $line = fgets($file_input);
      $p = strlen($line);
      echo $p;
      $a=2;
      if ($p == $a)
      {
          $m = $line[0];
          echo "$m\n";
  
          $l=0; $h=0;
          $filename=fopen("write.txt","r");
          $content=file("write.txt");
  
          for($i=0;$i&lt;$u-1;$i++)
          {
              $arr=$content[$i];
              $length=strlen($arr); 
  
              for($j=0;$j&lt;=$length;$j++)
              {
                  if(strcmp($arr[$j],$m ) == 0)// line 154
                  {
                      echo "\nYES PRESENT AT LINE NUMBER: ";
                      $h=$i+1;
                      echo "$h\n";
                      $l=$h+1;
                  }
              }
              break;
          }
          /********************************************************/             
          $arr3=$content[$l-2];// line 165
          $ar3=explode(" ",$arr3);
          $output_file=fopen("Result.txt","a");
          fwrite($output_file,$ar3[0]);
          fwrite($output_file," ");
          fclose($output_file);     
          $output_file=fopen("Result.txt","a");
          fwrite($output_file,$ar3[1]);
          fwrite($output_file," ");
          fclose($output_file);
          $ar3=str_replace("\n","",$ar3);
          $output_file=fopen("Result.txt","a");
          fwrite($output_file,$ar3[2]);
          fclose($output_file);
          /************************************************************/
          // put enter at the end of operation
          $output_file=fopen("Result.txt","a");
          fwrite($output_file,"\n");
          fclose($output_file);
          /**********************************************************/
  
  
      }
  </code></pre>