3v4l.org

run code in 300+ PHP versions simultaneously
<?php $custom_fields = [ 'foo' => '17', 'bar' => '17', ]; $time_intervals = ['day', 'month', 'year', 'hour', 'minute', 'period']; $data = [ 'fooday' => '17', 'foomonth' => 'March', 'name' => 'Chris' ]; function array_string_multiply() { $arrays = func_get_args(); $keys = array_keys(array_reduce($arrays, function ($keys, $arr) { return $keys + $arr; }, array())); $sums = array(); foreach ($keys as $key) { $sums[$key] = array_reduce($arrays, function ($sum, $arr) use ($key) { return $sum . @$arr[$key]; }); } return $sums; } foreach (array_string_multiply(array_keys($custom_fields), $time_intervals) as $key) { var_dump($key); } foreach (array_keys($custom_fields) as $name) { foreach ($time_intervals as $interval_name) { // ; } } var_dump($data); // Result should be array that only contains $data['name'] = 'Chris'
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 16
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 16
2 jumps found. (Code = 77) Position 1 = 21, Position 2 = 27
Branch analysis from position: 21
2 jumps found. (Code = 78) Position 1 = 22, Position 2 = 27
Branch analysis from position: 22
2 jumps found. (Code = 77) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
2 jumps found. (Code = 78) Position 1 = 24, Position 2 = 25
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 25
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
Branch analysis from position: 16
filename:       /in/DWQIH
function name:  (null)
number of ops:  32
compiled vars:  !0 = $custom_fields, !1 = $time_intervals, !2 = $data, !3 = $key, !4 = $name, !5 = $interval_name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    8     1        ASSIGN                                                   !1, <array>
   10     2        ASSIGN                                                   !2, <array>
   30     3        INIT_FCALL                                               'array_string_multiply'
          4        INIT_FCALL                                               'array_keys'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $9      
          7        SEND_VAR                                                 $9
          8        SEND_VAR                                                 !1
          9        DO_FCALL                                      0  $10     
         10      > FE_RESET_R                                       $11     $10, ->16
         11    > > FE_FETCH_R                                               $11, !3, ->16
   31    12    >   INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !3
         14        DO_ICALL                                                 
   30    15      > JMP                                                      ->11
         16    >   FE_FREE                                                  $11
   34    17        INIT_FCALL                                               'array_keys'
         18        SEND_VAR                                                 !0
         19        DO_ICALL                                         $13     
         20      > FE_RESET_R                                       $14     $13, ->27
         21    > > FE_FETCH_R                                               $14, !4, ->27
   35    22    > > FE_RESET_R                                       $15     !1, ->25
         23    > > FE_FETCH_R                                               $15, !5, ->25
         24    > > JMP                                                      ->23
         25    >   FE_FREE                                                  $15
   34    26      > JMP                                                      ->21
         27    >   FE_FREE                                                  $14
   41    28        INIT_FCALL                                               'var_dump'
         29        SEND_VAR                                                 !2
         30        DO_ICALL                                                 
   43    31      > RETURN                                                   1

Function array_string_multiply:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 24
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 24
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/DWQIH
function name:  array_string_multiply
number of ops:  27
compiled vars:  !0 = $arrays, !1 = $keys, !2 = $sums, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   FUNC_GET_ARGS                                    ~4      
          1        ASSIGN                                                   !0, ~4
   19     2        INIT_FCALL                                               'array_keys'
          3        INIT_FCALL                                               'array_reduce'
          4        SEND_VAR                                                 !0
          5        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FDWQIH%3A19%240'
          6        SEND_VAL                                                 ~6
          7        SEND_VAL                                                 <array>
          8        DO_ICALL                                         $7      
          9        SEND_VAR                                                 $7
         10        DO_ICALL                                         $8      
         11        ASSIGN                                                   !1, $8
   20    12        ASSIGN                                                   !2, <array>
   22    13      > FE_RESET_R                                       $11     !1, ->24
         14    > > FE_FETCH_R                                               $11, !3, ->24
   23    15    >   INIT_FCALL                                               'array_reduce'
         16        SEND_VAR                                                 !0
         17        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FDWQIH%3A23%241'
         18        BIND_LEXICAL                                             ~13, !3
         19        SEND_VAL                                                 ~13
         20        DO_ICALL                                         $14     
         21        ASSIGN_DIM                                               !2, !3
         22        OP_DATA                                                  $14
   22    23      > JMP                                                      ->14
         24    >   FE_FREE                                                  $11
   25    25      > RETURN                                                   !2
   26    26*     > RETURN                                                   null

End of function array_string_multiply

Function %00%7Bclosure%7D%2Fin%2FDWQIH%3A19%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DWQIH
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $keys, !1 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        ADD                                              ~2      !0, !1
          3      > RETURN                                                   ~2
          4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FDWQIH%3A19%240

Function %00%7Bclosure%7D%2Fin%2FDWQIH%3A23%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DWQIH
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $sum, !1 = $arr, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
          3        BEGIN_SILENCE                                    ~3      
          4        FETCH_DIM_R                                      ~4      !1, !2
          5        END_SILENCE                                              ~3
          6        CONCAT                                           ~5      !0, ~4
          7      > RETURN                                                   ~5
          8*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FDWQIH%3A23%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.78 ms | 1398 KiB | 20 Q