3v4l.org

run code in 300+ PHP versions simultaneously
<?php $itinerary = array (array('portName'=>'Day At Sea'), array('portName'=>'Moscow'), array('portName'=>'Jupiter')); $badPorts = array('At Sea', 'Day At Sea', 'Cruising The Mediterranean Sea'); $image = ''; $arr = array(); array_walk($itinerary, function($item, $index) use($badPorts, &$arr){ if(!in_array($item['portName'], $badPorts)) $arr[] = $index.":".$item['portName']; }); $image .= implode(',', $arr); var_dump($image); $image2 = ''; $arr2 = array(); foreach($itinerary as $index => $item){ if(!in_array($item['portName'], $badPorts)) $arr2[] = $index.":".$item['portName']; } $image2 .= implode(',', $arr2); var_dump($image2); $index = 0; $image3 = implode(',', array_reduce($itinerary, function ($result, $item) use($badPorts, &$index) { if(!in_array($item['portName'], $badPorts)) $result[] = $index.":".$item['portName']; return $result; }, array())); var_dump($image3);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 37
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 37
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 36
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 36
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
filename:       /in/iZAL3
function name:  (null)
number of ops:  64
compiled vars:  !0 = $itinerary, !1 = $badPorts, !2 = $image, !3 = $arr, !4 = $image2, !5 = $arr2, !6 = $item, !7 = $index, !8 = $image3
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    3     1        ASSIGN                                                   !1, <array>
    5     2        ASSIGN                                                   !2, ''
    6     3        ASSIGN                                                   !3, <array>
    7     4        INIT_FCALL                                               'array_walk'
          5        SEND_REF                                                 !0
          6        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FiZAL3%3A7%240'
          7        BIND_LEXICAL                                             ~13, !1
          8        BIND_LEXICAL                                             ~13, !3
    9     9        SEND_VAL                                                 ~13
         10        DO_ICALL                                                 
   10    11        INIT_FCALL                                               'implode'
         12        SEND_VAL                                                 '%2C'
         13        SEND_VAR                                                 !3
         14        DO_ICALL                                         $15     
         15        ASSIGN_OP                                     8          !2, $15
   11    16        INIT_FCALL                                               'var_dump'
         17        SEND_VAR                                                 !2
         18        DO_ICALL                                                 
   13    19        ASSIGN                                                   !4, ''
   14    20        ASSIGN                                                   !5, <array>
   15    21      > FE_RESET_R                                       $20     !0, ->37
         22    > > FE_FETCH_R                                       ~21     $20, !6, ->37
         23    >   ASSIGN                                                   !7, ~21
   16    24        INIT_FCALL                                               'in_array'
         25        FETCH_DIM_R                                      ~23     !6, 'portName'
         26        SEND_VAL                                                 ~23
         27        SEND_VAR                                                 !1
         28        DO_ICALL                                         $24     
         29        BOOL_NOT                                         ~25     $24
         30      > JMPZ                                                     ~25, ->36
         31    >   CONCAT                                           ~27     !7, '%3A'
         32        FETCH_DIM_R                                      ~28     !6, 'portName'
         33        CONCAT                                           ~29     ~27, ~28
         34        ASSIGN_DIM                                               !5
         35        OP_DATA                                                  ~29
   15    36    > > JMP                                                      ->22
         37    >   FE_FREE                                                  $20
   18    38        INIT_FCALL                                               'implode'
         39        SEND_VAL                                                 '%2C'
         40        SEND_VAR                                                 !5
         41        DO_ICALL                                         $30     
         42        ASSIGN_OP                                     8          !4, $30
   19    43        INIT_FCALL                                               'var_dump'
         44        SEND_VAR                                                 !4
         45        DO_ICALL                                                 
   21    46        ASSIGN                                                   !7, 0
   22    47        INIT_FCALL                                               'implode'
         48        SEND_VAL                                                 '%2C'
         49        INIT_FCALL                                               'array_reduce'
         50        SEND_VAR                                                 !0
         51        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FiZAL3%3A22%241'
         52        BIND_LEXICAL                                             ~34, !1
         53        BIND_LEXICAL                                             ~34, !7
   25    54        SEND_VAL                                                 ~34
         55        SEND_VAL                                                 <array>
         56        DO_ICALL                                         $35     
         57        SEND_VAR                                                 $35
         58        DO_ICALL                                         $36     
   22    59        ASSIGN                                                   !8, $36
   26    60        INIT_FCALL                                               'var_dump'
         61        SEND_VAR                                                 !8
         62        DO_ICALL                                                 
         63      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FiZAL3%3A7%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 16
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/iZAL3
function name:  {closure}
number of ops:  17
compiled vars:  !0 = $item, !1 = $index, !2 = $badPorts, !3 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
          3        BIND_STATIC                                              !3
    8     4        INIT_FCALL                                               'in_array'
          5        FETCH_DIM_R                                      ~4      !0, 'portName'
          6        SEND_VAL                                                 ~4
          7        SEND_VAR                                                 !2
          8        DO_ICALL                                         $5      
          9        BOOL_NOT                                         ~6      $5
         10      > JMPZ                                                     ~6, ->16
         11    >   CONCAT                                           ~8      !1, '%3A'
         12        FETCH_DIM_R                                      ~9      !0, 'portName'
         13        CONCAT                                           ~10     ~8, ~9
         14        ASSIGN_DIM                                               !3
         15        OP_DATA                                                  ~10
    9    16    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FiZAL3%3A7%240

Function %00%7Bclosure%7D%2Fin%2FiZAL3%3A22%241:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 16
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/iZAL3
function name:  {closure}
number of ops:  18
compiled vars:  !0 = $result, !1 = $item, !2 = $badPorts, !3 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
          3        BIND_STATIC                                              !3
   23     4        INIT_FCALL                                               'in_array'
          5        FETCH_DIM_R                                      ~4      !1, 'portName'
          6        SEND_VAL                                                 ~4
          7        SEND_VAR                                                 !2
          8        DO_ICALL                                         $5      
          9        BOOL_NOT                                         ~6      $5
         10      > JMPZ                                                     ~6, ->16
         11    >   CONCAT                                           ~8      !3, '%3A'
         12        FETCH_DIM_R                                      ~9      !1, 'portName'
         13        CONCAT                                           ~10     ~8, ~9
         14        ASSIGN_DIM                                               !0
         15        OP_DATA                                                  ~10
   24    16    > > RETURN                                                   !0
   25    17*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FiZAL3%3A22%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.69 ms | 1404 KiB | 23 Q