3v4l.org

run code in 300+ PHP versions simultaneously
<?php // $str = file_get_contents("text.txt"); $str = "1. Abuja, the Federal Capital Territory has -- -- -- -- -- area Council A. 4 B. 6 C. 7 D. 2 ANSWER: B 2. The Federal Capital Territory is associated with-- -- -- -- -- -- -- vegetation belt A. Sahel savanna B. Rainforest C. Guinea savanna D. Sudan savanna ANSWER: C 3. The most significant factor responsible for the ever increasing population of FCT is A. High birth rate B. Immigration C. Death rate D. CENSUS ANSWER: B"; $arr = explode("\n", $str); $res=[]; Foreach($arr as $line){ If($line != ""){ If(is_numeric($line[0])){ $res[$line[0]] =["QUESTION" =>explode(" ", $line,2)[1]]; $q = $line[0]; }Else if(ctype_alpha($line[0]) && $line[1] == "."){ $res[$q]["OPTIONS"][$line[0]] = explode(" ", $line, 2)[1]; }Else{ $res[$q]["ANSWER"] = explode(" ", $line, 2)[1]; } } } Var_dump($res);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 60
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 60
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 59
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 29
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 29
2 jumps found. (Code = 46) Position 1 = 34, Position 2 = 37
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 50
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
Branch analysis from position: 50
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 37
Branch analysis from position: 59
Branch analysis from position: 60
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 60
filename:       /in/n0PMr
function name:  (null)
number of ops:  65
compiled vars:  !0 = $str, !1 = $arr, !2 = $res, !3 = $line, !4 = $q
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '1.+Abuja%2C+the+Federal+Capital+Territory+has+--+--+--+--+--+area+Council%0AA.+4%0AB.+6%0AC.+7%0AD.+2%0AANSWER%3A+B%0A%0A2.+The+Federal+Capital+Territory+is+associated+with--+--+--+--+--+--+--+vegetation+belt%0AA.+Sahel+savanna%0AB.+Rainforest%0AC.+Guinea+savanna%0AD.+Sudan+savanna%0AANSWER%3A+C%0A%0A3.+The+most+significant+factor+responsible+for+the+ever+increasing+population+of+FCT+is%0AA.+High+birth+rate%0AB.+Immigration%0AC.+Death+rate%0AD.+CENSUS%0AANSWER%3A+B'
   24     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%0A'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $6      
          5        ASSIGN                                                   !1, $6
   26     6        ASSIGN                                                   !2, <array>
   28     7      > FE_RESET_R                                       $9      !1, ->60
          8    > > FE_FETCH_R                                               $9, !3, ->60
   29     9    >   IS_NOT_EQUAL                                             !3, ''
         10      > JMPZ                                                     ~10, ->59
   30    11    >   INIT_FCALL                                               'is_numeric'
         12        FETCH_DIM_R                                      ~11     !3, 0
         13        SEND_VAL                                                 ~11
         14        DO_ICALL                                         $12     
         15      > JMPZ                                                     $12, ->29
   31    16    >   FETCH_DIM_R                                      ~13     !3, 0
         17        INIT_FCALL                                               'explode'
         18        SEND_VAL                                                 '+'
         19        SEND_VAR                                                 !3
         20        SEND_VAL                                                 2
         21        DO_ICALL                                         $15     
         22        FETCH_DIM_R                                      ~16     $15, 1
         23        INIT_ARRAY                                       ~17     ~16, 'QUESTION'
         24        ASSIGN_DIM                                               !2, ~13
         25        OP_DATA                                                  ~17
   32    26        FETCH_DIM_R                                      ~18     !3, 0
         27        ASSIGN                                                   !4, ~18
         28      > JMP                                                      ->59
   33    29    >   INIT_FCALL                                               'ctype_alpha'
         30        FETCH_DIM_R                                      ~20     !3, 0
         31        SEND_VAL                                                 ~20
         32        DO_ICALL                                         $21     
         33      > JMPZ_EX                                          ~22     $21, ->37
         34    >   FETCH_DIM_R                                      ~23     !3, 1
         35        IS_EQUAL                                         ~24     ~23, '.'
         36        BOOL                                             ~22     ~24
         37    > > JMPZ                                                     ~22, ->50
   34    38    >   FETCH_DIM_R                                      ~27     !3, 0
         39        INIT_FCALL                                               'explode'
         40        SEND_VAL                                                 '+'
         41        SEND_VAR                                                 !3
         42        SEND_VAL                                                 2
         43        DO_ICALL                                         $29     
         44        FETCH_DIM_R                                      ~30     $29, 1
         45        FETCH_DIM_W                                      $25     !2, !4
         46        FETCH_DIM_W                                      $26     $25, 'OPTIONS'
         47        ASSIGN_DIM                                               $26, ~27
         48        OP_DATA                                                  ~30
         49      > JMP                                                      ->59
   36    50    >   INIT_FCALL                                               'explode'
         51        SEND_VAL                                                 '+'
         52        SEND_VAR                                                 !3
         53        SEND_VAL                                                 2
         54        DO_ICALL                                         $33     
         55        FETCH_DIM_R                                      ~34     $33, 1
         56        FETCH_DIM_W                                      $31     !2, !4
         57        ASSIGN_DIM                                               $31, 'ANSWER'
         58        OP_DATA                                                  ~34
   28    59    > > JMP                                                      ->8
         60    >   FE_FREE                                                  $9
   41    61        INIT_FCALL                                               'var_dump'
         62        SEND_VAR                                                 !2
         63        DO_ICALL                                                 
         64      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.04 ms | 1400 KiB | 21 Q