使用php浏览txt文件,搜索并显示特定内容

I have made a simple form with textfields, when i submit a button it wrties all textfield values into a .txt file. Here is an example of the .txt file content:

-----------------------------
How much is 1+1
3
4
5
1
-----------------------------

The 1st and last line ---- is there to just seperate data. The 1st line after the ---- is the question , the before the bottom seperator (1) is the true answer, and all the values between question and true answer are false answers.

What i want to do now is echo out the question , false answers and true answer , seperatly:

 echo $quesiton;
 print_r ($false_answers); //because it will be an array
 echo $true answer;

I think the solution is strpos , but i dont know how to use it the way i want it to. Can i do somethinglike this? :

 Select 1st line (question) after the 1st seperator
 Select 1st line (true answer) before the 2nd seperator
 Select all values inbetween question and true answer

Note that im only showing one example, the .txt file has a lot of these questions seperated with -------.

Are my thoughs correct about using strpos to solve this? Any suggestions?

Edit: Found some function:

$lines = file_get_contents('quiz.txt');
$start = "-----------------------------";
$end = "-----------------------------";

$pattern = sprintf('/%s(.+?)%s/ims',preg_quote($start, '/'), preg_quote($end, '/'));
if (preg_match($pattern, $lines, $matches)) {
    list(, $match) = $matches;
    echo $match;
}

I think this might work, not sure yet.

You may try this:

$file = fopen("test.txt","r");
$response = array();
while(! feof($file)) {
    $response[] = fgets($file);
}
fclose($file);

This way you will get response array like:

Array(
    [0]=>'--------------',
    [1]=>'How much is 1+1',
    [2]=>'3',
    [3]=>'4',
    [4]=>'2',
    [5]=>'1',
    [6]=>'--------------'
)

You could try something like this:

$lines = file_get_contents('quiz.txt');
$newline = "
"; //May need to be "
".
$delimiter = "-----------------------------". $newline; 
$question_blocks = explode($delimiter, $lines); 
$questions = array();
foreach ($question_blocks as $qb) {
   $items = explode ($newline, $qb);
   $q['question'] = array_shift($items);  //First item is the question
   $q['true_answer'] = array_pop($items);  //Last item is the true answer
   $q['false_answers'] = $items; //Rest of items are false answers.
   $questions[] = $q;
}
print_r($questions);