title: Random access file in PHP
body: <p>Is there some PHP function or class that allows me to read a file like an array of characters?</p>
  
  <p>For example:</p>
  
  <pre><code>$string = str_split('blabla');
  
  $i = 0;
  
  switch($string[$i]){
  
    case 'x':
      do_something();
      $i++;
  
  
    case 'y':
      if(isset($string[++$i]))
        do_something_else();
      else
        break;
  
     case 'z':
        // recursive call of this code etc..
  
  }
  </code></pre>
  
  <p>I know that I can use <code>$string = file_get_contents($file)</code>, but the problem is that I get a huge amount of memory used for a tiny 800K file (like 80MB).</p>
  
  <p>So can I somehow "stream" the file in my code above with some kind of arrayaccess like class that automatically reads data from the file when I call isset()  ? :)</p>