title: Scanning a Text File Line by Line in PHP
body: <p>So I have been working recently on a questionnaire script in php and I wrote a tool that would output a single txt file with a list of questions, each on it's own line. The file would look like so..</p>
  
  <p><strong>1 "Shopping for items is very important to me.." 2 3 4 5s 6</strong>   <em>//notice the 5s</em></p>
  
  <p><strong>2 "I love it when it is a rainy day" 4 8s 12 16 32s</strong></p>
  
  <p>The first number is the Questions id number. Next within the double quotes is the question itself.</p>
  
  <p>The next numbers that follow are id's of other questions that relate to that questions.</p>
  
  <p>In the case of "5s", that is a special question and I want the file reader to detect if the number has an s after it.</p>
  
  <pre><code>$file = fopen("output.txt", "r");
  $data = array();
  
  while (!feof($file)) 
  {
     $data[] = fgets(trim($file));
  }
  
  fclose($file);
  
  // Now I have an Array of strings line by line
  // Whats next now?? 
  </code></pre>
  
  <p>My question is how can I code something that will read the file in this order: </p>
  
  <p>(1)..The Question's ID number.. </p>
  
  <p>("Shopping for items is very important to me..")...Then the actual question itself disregarding the double quotes</p>
  
  <p>(2 3 4 5s 6)...Then the actual numbers while being aware that some may be 'special'.</p>
  
  <p>Can Someone PLease Help Me!!! THANKS!! </p>