Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>// Set up some variables $question = $choice1 = $choice2 = $choice3 = $correct = array(); $string = '1. An FMS system, besides controlling navigation, thrust and auto-nav, also provides: a) take-off and landing warnings * b) dedicated status and warnings c) GPWS warnings 2. EADI sky and ground display is provided by: a) synthetic TV signals * b) raster scan c) stroke pulse'; // Break question string into an array of questions with answers $data = explode("\r\n\r\n", $string); // Iterate through each question with answers foreach ($data AS $i =&gt; $tmp) { // Extract question and answers preg_match('/\d+\. (.*):\r\n(\*?)\ ?[abc]\) (.*)\r\n(\*?)\ ?[abc]\)\ (.*)\r\n(\*?)\ ?[abc]\)\ (.*)/s', $tmp, $matches); // Assign matches to variables $question[$i] = $matches[1]; $choice1[$i] = $matches[3]; $choice2[$i] = $matches[5]; $choice3[$i] = $matches[7]; // Figure out which answer is correct if ($matches[2] == '*') { $correct[$i] = 1; } else if ($matches[4] == '*') { $correct[$i] = 2; } else if ($matches[6] == '*') { $correct[$i] = 3; } } var_dump($question, $choice1, $choice2, $choice3, $correct); </code></pre> <p>Outputs:</p> <pre><code>// $question array(2) { [0]=&gt; string(82) "An FMS system, besides controlling navigation, thrust and auto-nav, also provides" [1]=&gt; string(42) "EADI sky and ground display is provided by" } // $choice1 array(2) { [0]=&gt; string(29) "take-off and landing warnings" [1]=&gt; string(20) "synthetic TV signals" } // $choice2 array(2) { [0]=&gt; string(29) "dedicated status and warnings" [1]=&gt; string(11) "raster scan" } // $choice3 array(2) { [0]=&gt; string(13) "GPWS warnings" [1]=&gt; string(12) "stroke pulse" } // $correct array(2) { [0]=&gt; int(2) [1]=&gt; int(2) } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload