title: PHP Notice: Undefined offset: 0
body: <p>I receive the following PHP notice</p>
  
  <pre><code>PHP Notice:  Undefined offset: 0
  </code></pre>
  
  <p>Here is a sample of what causes the error.</p>
  
  <pre><code>$file = $_SERVER['DOCUMENT_ROOT']."/savedposts/edited".$post_id.".txt";
  
  $saved_content = file_get_contents($_SERVER['DOCUMENT_ROOT']."/savedposts/".$post_id.".txt");
  $cct = 0;
  $contexttext = array();
  for ($i = 0; $i &lt; strlen($saved_content); $i++) {
      if (substr($saved_content, $i, 9) == "[Context]") {
          $i = $i + 9;
          while (substr($saved_content, $i, 10) !== "[/Context]") {
              $contexttext[$cct] .= substr($saved_content, $i, 1);
              $i++;
          } 
      $cct++;
      }
  }
  </code></pre>
  
  <p>The error is on this line </p>
  
  <pre><code>$contexttext[$cct] .= substr($saved_content, $i, 1);
  </code></pre>
  
  <p>How to fix the notice.</p>