3v4l.org

run code in 300+ PHP versions simultaneously
<?php $movie_list = <<<DATA { "type" : ["movie", "movie", "movie", "tv_show"], "year" : ["2018", "2018", "2018", null ], "movies" : ["Movie 1", "Movie 2", "Movie 3", "TV Show 1"], "season_num" : [null, null, null, "5"], "episode_num" : [null, null, null, "5"], "times" : ["6390.629196248", "6542.58813267", "1988.046243357", "766.892506912"] } DATA; $movie_list = json_decode($movie_list, true); function iterate_movies($movies) { foreach ($movies['movies'] as $i => $name) { $movie = ['name' => $name]; foreach (['type', 'year', 'season_num', 'episode_num', 'times'] as $property) { $movie[$property] = $movies[$property][$i]; } yield $movie; } } foreach (iterate_movies($movie_list) as $movie) { $title = $movie['type'] == 'tv_show' ? sprintf('%s-%d.%d', $movie['name'], $movie['season_num'], $movie['episode_num']) : $movie['name']; ?> <tr> <td><?= htmlspecialchars($title) ?></td> <td><?= htmlspecialchars($movie['times']) ?></td> </tr> <?php }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 41
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 41
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 25
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
filename:       /in/fSvpg
function name:  (null)
number of ops:  43
compiled vars:  !0 = $movie_list, !1 = $movie, !2 = $title
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%7B%0A++++%22type%22+%3A+%5B%22movie%22%2C+%22movie%22%2C+%22movie%22%2C+%22tv_show%22%5D%2C%0A++++%22year%22+%3A+%5B%222018%22%2C+%222018%22%2C+%222018%22%2C+null+%5D%2C%0A++++%22movies%22+%3A+%5B%22Movie+1%22%2C+%22Movie+2%22%2C+%22Movie+3%22%2C+%22TV+Show+1%22%5D%2C%0A++++%22season_num%22+%3A+%5Bnull%2C+null%2C+null%2C+%225%22%5D%2C%0A++++%22episode_num%22+%3A+%5Bnull%2C+null%2C+null%2C+%225%22%5D%2C%0A++++%22times%22+%3A+%5B%226390.629196248%22%2C+%226542.58813267%22%2C+%221988.046243357%22%2C+%22766.892506912%22%5D%0A%7D'
   13     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $4      
          5        ASSIGN                                                   !0, $4
   26     6        INIT_FCALL                                               'iterate_movies'
          7        SEND_VAR                                                 !0
          8        DO_FCALL                                      0  $6      
          9      > FE_RESET_R                                       $7      $6, ->41
         10    > > FE_FETCH_R                                               $7, !1, ->41
   27    11    >   FETCH_DIM_R                                      ~8      !1, 'type'
         12        IS_EQUAL                                                 ~8, 'tv_show'
         13      > JMPZ                                                     ~9, ->25
   28    14    >   INIT_FCALL                                               'sprintf'
         15        SEND_VAL                                                 '%25s-%25d.%25d'
         16        FETCH_DIM_R                                      ~10     !1, 'name'
         17        SEND_VAL                                                 ~10
         18        FETCH_DIM_R                                      ~11     !1, 'season_num'
         19        SEND_VAL                                                 ~11
         20        FETCH_DIM_R                                      ~12     !1, 'episode_num'
         21        SEND_VAL                                                 ~12
         22        DO_ICALL                                         $13     
         23        QM_ASSIGN                                        ~14     $13
         24      > JMP                                                      ->27
   29    25    >   FETCH_DIM_R                                      ~15     !1, 'name'
         26        QM_ASSIGN                                        ~14     ~15
   27    27    >   ASSIGN                                                   !2, ~14
   31    28        ECHO                                                     '%3Ctr%3E%0A++%3Ctd%3E'
   32    29        INIT_FCALL                                               'htmlspecialchars'
         30        SEND_VAR                                                 !2
         31        DO_ICALL                                         $17     
         32        ECHO                                                     $17
         33        ECHO                                                     '%3C%2Ftd%3E%0A++%3Ctd%3E'
   33    34        INIT_FCALL                                               'htmlspecialchars'
         35        FETCH_DIM_R                                      ~18     !1, 'times'
         36        SEND_VAL                                                 ~18
         37        DO_ICALL                                         $19     
         38        ECHO                                                     $19
         39        ECHO                                                     '%3C%2Ftd%3E%0A%3C%2Ftr%3E%0A'
   26    40      > JMP                                                      ->10
         41    >   FE_FREE                                                  $7
   36    42      > RETURN                                                   1

Function iterate_movies:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 18
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 18
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 15
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 15
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 15
Branch analysis from position: 18
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 18
filename:       /in/fSvpg
function name:  iterate_movies
number of ops:  20
compiled vars:  !0 = $movies, !1 = $name, !2 = $i, !3 = $movie, !4 = $property
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
   17     2        FETCH_DIM_R                                      ~5      !0, 'movies'
          3      > FE_RESET_R                                       $6      ~5, ->18
          4    > > FE_FETCH_R                                       ~7      $6, !1, ->18
          5    >   ASSIGN                                                   !2, ~7
   18     6        INIT_ARRAY                                       ~9      !1, 'name'
          7        ASSIGN                                                   !3, ~9
   19     8      > FE_RESET_R                                       $11     <array>, ->15
          9    > > FE_FETCH_R                                               $11, !4, ->15
   20    10    >   FETCH_DIM_R                                      ~13     !0, !4
         11        FETCH_DIM_R                                      ~14     ~13, !2
         12        ASSIGN_DIM                                               !3, !4
         13        OP_DATA                                                  ~14
   19    14      > JMP                                                      ->9
         15    >   FE_FREE                                                  $11
   22    16        YIELD                                                    !3
   17    17      > JMP                                                      ->4
         18    >   FE_FREE                                                  $6
   24    19      > GENERATOR_RETURN                                         

End of function iterate_movies

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.94 ms | 1011 KiB | 17 Q