3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [ 'name' => 'Bar', 'location' => 'Baz', 'foo.2021-02-01' => '50000.00', 'foo.2021-03-01' => '50000.00', 'foo.2021-04-01' => '50000.00', 'foo.2021-05-01' => '' ]; $result = []; foreach ($array as $key => $value) { if (preg_match('~^foo\.\K\d{4}-\d{2}-\d{2}$~', $key, $m)) { $result[] = ['date' => $m[0], 'value' => $value]; } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 17
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 17
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 16
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 16
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/4aW7U
function name:  (null)
number of ops:  22
compiled vars:  !0 = $array, !1 = $result, !2 = $value, !3 = $key, !4 = $m
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   12     1        ASSIGN                                                       !1, <array>
   13     2      > FE_RESET_R                                           $7      !0, ->17
          3    > > FE_FETCH_R                                           ~8      $7, !2, ->17
          4    >   ASSIGN                                                       !3, ~8
   14     5        INIT_FCALL                                                   'preg_match'
          6        SEND_VAL                                                     '%7E%5Efoo%5C.%5CK%5Cd%7B4%7D-%5Cd%7B2%7D-%5Cd%7B2%7D%24%7E'
          7        SEND_VAR                                                     !3
          8        SEND_REF                                                     !4
          9        DO_ICALL                                             $10     
         10      > JMPZ                                                         $10, ->16
   15    11    >   FETCH_DIM_R                                          ~12     !4, 0
         12        INIT_ARRAY                                           ~13     ~12, 'date'
         13        ADD_ARRAY_ELEMENT                                    ~13     !2, 'value'
         14        ASSIGN_DIM                                                   !1
         15        OP_DATA                                                      ~13
   13    16    > > JMP                                                          ->3
         17    >   FE_FREE                                                      $7
   18    18        INIT_FCALL                                                   'var_export'
         19        SEND_VAR                                                     !1
         20        DO_ICALL                                                     
         21      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
130.58 ms | 478 KiB | 9 Q