3v4l.org

run code in 300+ PHP versions simultaneously
<?php function flatMap (array $array, callable $function): array { $output = []; foreach ($array as $value) { $tmp = $function($value); foreach ($tmp as $row) { $output[] = $row; } } return $output; } $example = [ ['schools' => '001|002|003'], ['schools' => '004|005|006'], ['schools' => '007|008|009'], ]; var_dump( flatMap($example, function ($record) { return explode('|', $record['schools']); }) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/X2AqR
function name:  (null)
number of ops:  10
compiled vars:  !0 = $example
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                   !0, <array>
   24     1        INIT_FCALL                                               'var_dump'
   25     2        INIT_FCALL                                               'flatmap'
          3        SEND_VAR                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FX2AqR%3A25%240'
   27     5        SEND_VAL                                                 ~2
          6        DO_FCALL                                      0  $3      
          7        SEND_VAR                                                 $3
          8        DO_ICALL                                                 
   28     9      > RETURN                                                   1

Function flatmap:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 16
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 16
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 14
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 14
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/X2AqR
function name:  flatMap
number of ops:  21
compiled vars:  !0 = $array, !1 = $function, !2 = $output, !3 = $value, !4 = $tmp, !5 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        ASSIGN                                                   !2, <array>
    6     3      > FE_RESET_R                                       $7      !0, ->16
          4    > > FE_FETCH_R                                               $7, !3, ->16
    7     5    >   INIT_DYNAMIC_CALL                                        !1
          6        SEND_VAR_EX                                              !3
          7        DO_FCALL                                      0  $8      
          8        ASSIGN                                                   !4, $8
    9     9      > FE_RESET_R                                       $10     !4, ->14
         10    > > FE_FETCH_R                                               $10, !5, ->14
   10    11    >   ASSIGN_DIM                                               !2
         12        OP_DATA                                                  !5
    9    13      > JMP                                                      ->10
         14    >   FE_FREE                                                  $10
    6    15      > JMP                                                      ->4
         16    >   FE_FREE                                                  $7
   14    17        VERIFY_RETURN_TYPE                                       !2
         18      > RETURN                                                   !2
   15    19*       VERIFY_RETURN_TYPE                                       
         20*     > RETURN                                                   null

End of function flatmap

Function %00%7Bclosure%7D%2Fin%2FX2AqR%3A25%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/X2AqR
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $record
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
   26     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%7C'
          3        FETCH_DIM_R                                      ~1      !0, 'schools'
          4        SEND_VAL                                                 ~1
          5        DO_ICALL                                         $2      
          6      > RETURN                                                   $2
   27     7*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FX2AqR%3A25%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.99 ms | 1403 KiB | 18 Q