3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tests = array("HIV", "Chlamydia", "Gonorrhoea"); $years = [ '2011' => false, '2012' => false, '2013' => false, '2014' => false, '2015' => false, '2016' => false, '2017' => false ]; $this_year = date('Y'); if (!array_key_exists($this_year, $years)) { // add to the array: $years[$this_year] = false; } $tests_by_year = []; $test_obj = []; $obj_count = count($years); $obj_added = 0; foreach ( $tests as $value ) { foreach ($years as $year => $yval) { $tests_by_year[$value][$year] = 0; if ($obj_added <= $obj_count) { $test_obj[] = new \stdClass; } $obj_added++; } } var_dump($test_obj); $test_obj2 = [ 0 => new \stdClass, 1 => new \stdClass, 2 => new \stdClass, 3 => new \stdClass, 4 => new \stdClass, 5 => new \stdClass, 6 => new \stdClass, 7 => new \stdClass, 8 => new \stdClass, 9 => new \stdClass ]; $test_obj2[0]->y = (int)2011; $test_obj2[1]->y = (int)2012; $test_obj2[2]->y = (int)2013; $test_obj2[3]->y = (int)2014; $test_obj2[4]->y = (int)2015; $test_obj2[5]->y = (int)2016; $test_obj2[6]->y = (int)2017; $test_obj2[7]->y = (int)2018; $test_obj2[8]->y = (int)2019; $test_obj2[9]->y = (int)2020; var_dump($test_obj2); /* foreach ($tests_by_year as $key => $value) { $test_obj[0]->$key = $value['2011']; $test_obj[1]->$key = $value['2012']; $test_obj[2]->$key = $value['2013']; $test_obj[3]->$key = $value['2014']; $test_obj[4]->$key = $value['2015']; $test_obj[5]->$key = $value['2016']; $test_obj[6]->$key = $value['2017']; $test_obj[7]->$key = $value['2018']; $test_obj[8]->$key = $value['2019']; $test_obj[9]->$key = $value['2020']; }*/
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 34
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 34
Branch analysis from position: 18
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 32
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 32
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 30
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 30
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 32
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
Branch analysis from position: 11
filename:       /in/ttWed
function name:  (null)
number of ops:  113
compiled vars:  !0 = $tests, !1 = $years, !2 = $this_year, !3 = $tests_by_year, !4 = $test_obj, !5 = $obj_count, !6 = $obj_added, !7 = $value, !8 = $yval, !9 = $year, !10 = $test_obj2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
   14     2        INIT_FCALL                                               'date'
          3        SEND_VAL                                                 'Y'
          4        DO_ICALL                                         $13     
          5        ASSIGN                                                   !2, $13
   16     6        ARRAY_KEY_EXISTS                                 ~15     !2, !1
          7        BOOL_NOT                                         ~16     ~15
          8      > JMPZ                                                     ~16, ->11
   19     9    >   ASSIGN_DIM                                               !1, !2
         10        OP_DATA                                                  <false>
   23    11    >   ASSIGN                                                   !3, <array>
   24    12        ASSIGN                                                   !4, <array>
   25    13        COUNT                                            ~20     !1
         14        ASSIGN                                                   !5, ~20
   26    15        ASSIGN                                                   !6, 0
   28    16      > FE_RESET_R                                       $23     !0, ->34
         17    > > FE_FETCH_R                                               $23, !7, ->34
   30    18    > > FE_RESET_R                                       $24     !1, ->32
         19    > > FE_FETCH_R                                       ~25     $24, !8, ->32
         20    >   ASSIGN                                                   !9, ~25
   32    21        FETCH_DIM_W                                      $27     !3, !7
         22        ASSIGN_DIM                                               $27, !9
         23        OP_DATA                                                  0
   34    24        IS_SMALLER_OR_EQUAL                                      !6, !5
         25      > JMPZ                                                     ~29, ->30
   35    26    >   NEW                                              $31     'stdClass'
         27        DO_FCALL                                      0          
         28        ASSIGN_DIM                                               !4
         29        OP_DATA                                                  $31
   38    30    >   PRE_INC                                                  !6
   30    31      > JMP                                                      ->19
         32    >   FE_FREE                                                  $24
   28    33      > JMP                                                      ->17
         34    >   FE_FREE                                                  $23
   44    35        INIT_FCALL                                               'var_dump'
         36        SEND_VAR                                                 !4
         37        DO_ICALL                                                 
   46    38        NEW                                              $35     'stdClass'
         39        DO_FCALL                                      0          
         40        INIT_ARRAY                                       ~37     $35, 0
   47    41        NEW                                              $38     'stdClass'
         42        DO_FCALL                                      0          
         43        ADD_ARRAY_ELEMENT                                ~37     $38, 1
   48    44        NEW                                              $40     'stdClass'
         45        DO_FCALL                                      0          
         46        ADD_ARRAY_ELEMENT                                ~37     $40, 2
   49    47        NEW                                              $42     'stdClass'
         48        DO_FCALL                                      0          
         49        ADD_ARRAY_ELEMENT                                ~37     $42, 3
   50    50        NEW                                              $44     'stdClass'
         51        DO_FCALL                                      0          
         52        ADD_ARRAY_ELEMENT                                ~37     $44, 4
   51    53        NEW                                              $46     'stdClass'
         54        DO_FCALL                                      0          
         55        ADD_ARRAY_ELEMENT                                ~37     $46, 5
   52    56        NEW                                              $48     'stdClass'
         57        DO_FCALL                                      0          
         58        ADD_ARRAY_ELEMENT                                ~37     $48, 6
   53    59        NEW                                              $50     'stdClass'
         60        DO_FCALL                                      0          
         61        ADD_ARRAY_ELEMENT                                ~37     $50, 7
   54    62        NEW                                              $52     'stdClass'
         63        DO_FCALL                                      0          
         64        ADD_ARRAY_ELEMENT                                ~37     $52, 8
   55    65        NEW                                              $54     'stdClass'
         66        DO_FCALL                                      0          
         67        ADD_ARRAY_ELEMENT                                ~37     $54, 9
   45    68        ASSIGN                                                   !10, ~37
   58    69        CAST                                          4  ~59     2011
         70        FETCH_DIM_W                                      $57     !10, 0
         71        ASSIGN_OBJ                                               $57, 'y'
         72        OP_DATA                                                  ~59
   59    73        CAST                                          4  ~62     2012
         74        FETCH_DIM_W                                      $60     !10, 1
         75        ASSIGN_OBJ                                               $60, 'y'
         76        OP_DATA                                                  ~62
   60    77        CAST                                          4  ~65     2013
         78        FETCH_DIM_W                                      $63     !10, 2
         79        ASSIGN_OBJ                                               $63, 'y'
         80        OP_DATA                                                  ~65
   61    81        CAST                                          4  ~68     2014
         82        FETCH_DIM_W                                      $66     !10, 3
         83        ASSIGN_OBJ                                               $66, 'y'
         84        OP_DATA                                                  ~68
   62    85        CAST                                          4  ~71     2015
         86        FETCH_DIM_W                                      $69     !10, 4
         87        ASSIGN_OBJ                                               $69, 'y'
         88        OP_DATA                                                  ~71
   63    89        CAST                                          4  ~74     2016
         90        FETCH_DIM_W                                      $72     !10, 5
         91        ASSIGN_OBJ                                               $72, 'y'
         92        OP_DATA                                                  ~74
   64    93        CAST                                          4  ~77     2017
         94        FETCH_DIM_W                                      $75     !10, 6
         95        ASSIGN_OBJ                                               $75, 'y'
         96        OP_DATA                                                  ~77
   65    97        CAST                                          4  ~80     2018
         98        FETCH_DIM_W                                      $78     !10, 7
         99        ASSIGN_OBJ                                               $78, 'y'
        100        OP_DATA                                                  ~80
   66   101        CAST                                          4  ~83     2019
        102        FETCH_DIM_W                                      $81     !10, 8
        103        ASSIGN_OBJ                                               $81, 'y'
        104        OP_DATA                                                  ~83
   67   105        CAST                                          4  ~86     2020
        106        FETCH_DIM_W                                      $84     !10, 9
        107        ASSIGN_OBJ                                               $84, 'y'
        108        OP_DATA                                                  ~86
   69   109        INIT_FCALL                                               'var_dump'
        110        SEND_VAR                                                 !10
        111        DO_ICALL                                                 
   84   112      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.64 ms | 1404 KiB | 17 Q