3v4l.org

run code in 300+ PHP versions simultaneously
<?php function partial(callable $callable, ...$initialargs): callable { return fn (...$args) => $callable(...$initialargs, ...$args); } $data = [ [ 'quiz' => 2, 'question' => 7, 'notif' => 'sup' ], [ 'quiz' => 3, 'question' => 7, 'notif' => 'pus' ], [ 'quiz' => 2, 'question' => 3, 'notif' => 'yoyoyo' ] ]; $keys = fn(array $data, string $key): callable => partial(array_keys(...), array_column($data, $key)); $indices = fn(array $data, string $key): array => array_map($keys($data, $key), array_column($data, $key, $key)); $map = fn(array $data): callable => partial(array_map(...), fn(int $i): array => $data[$i]); $byx = fn(array $data, string $x): array => array_map($map, $indices($data, $x)); $byquiz = $byx($data, 'quiz'); $byquizandquestion = array_map(fn($d) => $byx($d, 'question'), $byquiz); print_r($byquizandquestion);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/McAek
function name:  (null)
number of ops:  29
compiled vars:  !0 = $data, !1 = $keys, !2 = $indices, !3 = $map, !4 = $i, !5 = $byx, !6 = $byquiz, !7 = $byquizandquestion
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ASSIGN                                                   !0, <array>
   25     1        DECLARE_LAMBDA_FUNCTION                          ~9      [0]
          2        ASSIGN                                                   !1, ~9
   26     3        DECLARE_LAMBDA_FUNCTION                          ~11     [1]
          4        BIND_LEXICAL                                             ~11, !1
          5        ASSIGN                                                   !2, ~11
   27     6        DECLARE_LAMBDA_FUNCTION                          ~13     [2]
          7        BIND_LEXICAL                                             ~13, !4
          8        ASSIGN                                                   !3, ~13
   28     9        DECLARE_LAMBDA_FUNCTION                          ~15     [3]
         10        BIND_LEXICAL                                             ~15, !3
         11        BIND_LEXICAL                                             ~15, !2
         12        ASSIGN                                                   !5, ~15
   30    13        INIT_DYNAMIC_CALL                                        !5
         14        SEND_VAR_EX                                              !0
         15        SEND_VAL_EX                                              'quiz'
         16        DO_FCALL                                      0  $17     
         17        ASSIGN                                                   !6, $17
   31    18        INIT_FCALL                                               'array_map'
         19        DECLARE_LAMBDA_FUNCTION                          ~19     [4]
         20        BIND_LEXICAL                                             ~19, !5
         21        SEND_VAL                                                 ~19
         22        SEND_VAR                                                 !6
         23        DO_ICALL                                         $20     
         24        ASSIGN                                                   !7, $20
   32    25        INIT_FCALL                                               'print_r'
         26        SEND_VAR                                                 !7
         27        DO_ICALL                                                 
         28      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/McAek
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $data, !1 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        INIT_FCALL                                               'partial'
          3        INIT_FCALL                                               'array_keys'
          4        ZEND_CALLABLE_CONVERT                            ~2      
          5        SEND_VAL                                                 ~2
          6        INIT_FCALL                                               'array_column'
          7        SEND_VAR                                                 !0
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $3      
         10        SEND_VAR                                                 $3
         11        DO_FCALL                                      0  $4      
         12        VERIFY_RETURN_TYPE                                       $4
         13      > RETURN                                                   $4
         14*       VERIFY_RETURN_TYPE                                       
         15*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/McAek
function name:  {closure}
number of ops:  20
compiled vars:  !0 = $data, !1 = $key, !2 = $keys
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
          3        INIT_FCALL                                               'array_map'
          4        INIT_DYNAMIC_CALL                                        !2
          5        SEND_VAR_EX                                              !0
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0  $3      
          8        SEND_VAR                                                 $3
          9        INIT_FCALL                                               'array_column'
         10        SEND_VAR                                                 !0
         11        SEND_VAR                                                 !1
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                         $4      
         14        SEND_VAR                                                 $4
         15        DO_ICALL                                         $5      
         16        VERIFY_RETURN_TYPE                                       $5
         17      > RETURN                                                   $5
         18*       VERIFY_RETURN_TYPE                                       
         19*     > RETURN                                                   null

End of Dynamic Function 1

Dynamic Function 2
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/McAek
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $data, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        INIT_FCALL                                               'partial'
          3        INIT_FCALL                                               'array_map'
          4        ZEND_CALLABLE_CONVERT                            ~2      
          5        SEND_VAL                                                 ~2
          6        DECLARE_LAMBDA_FUNCTION                          ~3      [0]
          7        BIND_LEXICAL                                             ~3, !0
          8        SEND_VAL                                                 ~3
          9        DO_FCALL                                      0  $4      
         10        VERIFY_RETURN_TYPE                                       $4
         11      > RETURN                                                   $4
         12*       VERIFY_RETURN_TYPE                                       
         13*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/McAek
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $i, !1 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
          0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        FETCH_DIM_R                                      ~2      !1, !0
          3        VERIFY_RETURN_TYPE                                       ~2
          4      > RETURN                                                   ~2
          5*       VERIFY_RETURN_TYPE                                       
          6*     > RETURN                                                   null

End of Dynamic Function 0

End of Dynamic Function 2

Dynamic Function 3
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/McAek
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $data, !1 = $x, !2 = $map, !3 = $indices
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
          3        BIND_STATIC                                              !3
          4        INIT_FCALL                                               'array_map'
          5        SEND_VAR                                                 !2
          6        INIT_DYNAMIC_CALL                                        !3
          7        SEND_VAR_EX                                              !0
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0  $4      
         10        SEND_VAR                                                 $4
         11        DO_ICALL                                         $5      
         12        VERIFY_RETURN_TYPE                                       $5
         13      > RETURN                                                   $5
         14*       VERIFY_RETURN_TYPE                                       
         15*     > RETURN                                                   null

End of Dynamic Function 3

Dynamic Function 4
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/McAek
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $d, !1 = $byx
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        INIT_DYNAMIC_CALL                                        !1
          3        SEND_VAR_EX                                              !0
          4        SEND_VAL_EX                                              'question'
          5        DO_FCALL                                      0  $2      
          6      > RETURN                                                   $2
          7*     > RETURN                                                   null

End of Dynamic Function 4

Function partial:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/McAek
function name:  partial
number of ops:  9
compiled vars:  !0 = $callable, !1 = $initialargs
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_VARIADIC                                    !1      
    4     2        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
          3        BIND_LEXICAL                                             ~2, !0
          4        BIND_LEXICAL                                             ~2, !1
          5        VERIFY_RETURN_TYPE                                       ~2
          6      > RETURN                                                   ~2
    5     7*       VERIFY_RETURN_TYPE                                       
          8*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/McAek
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $args, !1 = $callable, !2 = $initialargs
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV_VARIADIC                                    !0      
          1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
          3        INIT_DYNAMIC_CALL                                        !1
          4        SEND_UNPACK                                              !2
          5        SEND_UNPACK                                              !0
          6        CHECK_UNDEF_ARGS                                         
          7        DO_FCALL                                      1  $3      
          8      > RETURN                                                   $3
          9*     > RETURN                                                   null

End of Dynamic Function 0

End of function partial

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.67 ms | 1478 KiB | 19 Q