3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ [ 'name' => 'Dick Jansen', 'matchedMovie' => [ [ 'nameMovie' => 'Saw', 'genre' => 'Horror', 'patheMovie' => 'Texas Chainsaw 3D', 'patheMovieGenre' => 'Horror', 'score' => '100.00', ] ] ], [ 'name' => 'Jim Scott', 'matchedMovie' => [ [ 'nameMovie' => 'Shooter', 'genre' => 'Action, Thriller', 'patheMovie' => 'The Shining', 'patheMovieGenre' => 'Horror, Suspense/Thriller', 'score' => '52.38', ], [ 'nameMovie' => 'Resident Evil Movie', 'genre' => 'Action/Horror', 'patheMovie' => 'Texas Chainsaw 3D', 'patheMovieGenre' => 'Horror', 'score' => '63.16', ] ] ] ]; function findMovieMatches(array $movies, string $movieName): array { $result = []; foreach ($movies as ['name' => $name, 'matchedMovie' => $matches]) { foreach ($matches as $entry) { if ($movieName === $entry['patheMovie']) { $result[] = ['name' => $name] + $entry; } } } return $result; } var_export(findMovieMatches($array, 'Texas Chainsaw 3D')); echo "\n---\n"; var_export(findMovieMatches($array, 'The Shining'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lXKQf
function name:  (null)
number of ops:  17
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   50     1        INIT_FCALL                                               'var_export'
          2        INIT_FCALL                                               'findmoviematches'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 'Texas+Chainsaw+3D'
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                                 
   51     8        ECHO                                                     '%0A---%0A'
   52     9        INIT_FCALL                                               'var_export'
         10        INIT_FCALL                                               'findmoviematches'
         11        SEND_VAR                                                 !0
         12        SEND_VAL                                                 'The+Shining'
         13        DO_FCALL                                      0  $4      
         14        SEND_VAR                                                 $4
         15        DO_ICALL                                                 
         16      > RETURN                                                   1

Function findmoviematches:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 22
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 22
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 20
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 20
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 19
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 19
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 20
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/lXKQf
function name:  findMovieMatches
number of ops:  27
compiled vars:  !0 = $movies, !1 = $movieName, !2 = $result, !3 = $name, !4 = $matches, !5 = $entry
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   39     2        ASSIGN                                                   !2, <array>
   40     3      > FE_RESET_R                                       $7      !0, ->22
          4    > > FE_FETCH_R                                               $7, $8, ->22
          5    >   FETCH_LIST_R                                     $9      $8, 'name'
          6        ASSIGN                                                   !3, $9
          7        FETCH_LIST_R                                     $11     $8, 'matchedMovie'
          8        ASSIGN                                                   !4, $11
          9        FREE                                                     $8
   41    10      > FE_RESET_R                                       $13     !4, ->20
         11    > > FE_FETCH_R                                               $13, !5, ->20
   42    12    >   FETCH_DIM_R                                      ~14     !5, 'patheMovie'
         13        IS_IDENTICAL                                             !1, ~14
         14      > JMPZ                                                     ~15, ->19
   43    15    >   INIT_ARRAY                                       ~17     !3, 'name'
         16        ADD                                              ~18     ~17, !5
         17        ASSIGN_DIM                                               !2
         18        OP_DATA                                                  ~18
   41    19    > > JMP                                                      ->11
         20    >   FE_FREE                                                  $13
   40    21      > JMP                                                      ->4
         22    >   FE_FREE                                                  $7
   47    23        VERIFY_RETURN_TYPE                                       !2
         24      > RETURN                                                   !2
   48    25*       VERIFY_RETURN_TYPE                                       
         26*     > RETURN                                                   null

End of function findmoviematches

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.7 ms | 1407 KiB | 17 Q