3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array("1" => "0", "2" => "5", "5" => "7", "1C" => "0", "2C" => "5", "5C" => "10", "1S" => "15", "5S" => "20"); $keyContainsC = []; array_walk($array, function ($value, $key) use (&$keyContainsC) { if (strpos($key, 'C') !== false) $keyContainsC[$key] = $value; }); print_r($keyContainsC); array_walk($array, function ($value, $key) use (&$result) { if (strpos($key, 'C') !== false) $result['C'][$key] = $value; if (strpos($key, 'S') !== false) $result['S'][$key] = $value; if (strpos($key, 'C') === false && strpos($key, 'S') === false) $result['NR'][$key] = $value; }); print_r($result['S']);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KOPhW
function name:  (null)
number of ops:  22
compiled vars:  !0 = $array, !1 = $keyContainsC, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    5     2        INIT_FCALL                                               'array_walk'
          3        SEND_REF                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
          5        BIND_LEXICAL                                             ~5, !1
    7     6        SEND_VAL                                                 ~5
    5     7        DO_ICALL                                                 
    9     8        INIT_FCALL                                               'print_r'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                                 
   11    11        INIT_FCALL                                               'array_walk'
         12        SEND_REF                                                 !0
         13        DECLARE_LAMBDA_FUNCTION                          ~8      [1]
         14        BIND_LEXICAL                                             ~8, !2
   15    15        SEND_VAL                                                 ~8
   11    16        DO_ICALL                                                 
   17    17        INIT_FCALL                                               'print_r'
         18        FETCH_DIM_R                                      ~10     !2, 'S'
         19        SEND_VAL                                                 ~10
         20        DO_ICALL                                                 
         21      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/KOPhW
function name:  {closure}
number of ops:  12
compiled vars:  !0 = $value, !1 = $key, !2 = $keyContainsC
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
    6     3        INIT_FCALL                                               'strpos'
          4        SEND_VAR                                                 !1
          5        SEND_VAL                                                 'C'
          6        DO_ICALL                                         $3      
          7        TYPE_CHECK                                  1018          $3
          8      > JMPZ                                                     ~4, ->11
          9    >   ASSIGN_DIM                                               !2, !1
         10        OP_DATA                                                  !0
    7    11    > > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
2 jumps found. (Code = 46) Position 1 = 27, Position 2 = 33
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 37
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
Branch analysis from position: 33
Branch analysis from position: 21
Branch analysis from position: 12
filename:       /in/KOPhW
function name:  {closure}
number of ops:  38
compiled vars:  !0 = $value, !1 = $key, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   12     3        INIT_FCALL                                               'strpos'
          4        SEND_VAR                                                 !1
          5        SEND_VAL                                                 'C'
          6        DO_ICALL                                         $3      
          7        TYPE_CHECK                                  1018          $3
          8      > JMPZ                                                     ~4, ->12
          9    >   FETCH_DIM_W                                      $5      !2, 'C'
         10        ASSIGN_DIM                                               $5, !1
         11        OP_DATA                                                  !0
   13    12    >   INIT_FCALL                                               'strpos'
         13        SEND_VAR                                                 !1
         14        SEND_VAL                                                 'S'
         15        DO_ICALL                                         $7      
         16        TYPE_CHECK                                  1018          $7
         17      > JMPZ                                                     ~8, ->21
         18    >   FETCH_DIM_W                                      $9      !2, 'S'
         19        ASSIGN_DIM                                               $9, !1
         20        OP_DATA                                                  !0
   14    21    >   INIT_FCALL                                               'strpos'
         22        SEND_VAR                                                 !1
         23        SEND_VAL                                                 'C'
         24        DO_ICALL                                         $11     
         25        TYPE_CHECK                                    4  ~12     $11
         26      > JMPZ_EX                                          ~12     ~12, ->33
         27    >   INIT_FCALL                                               'strpos'
         28        SEND_VAR                                                 !1
         29        SEND_VAL                                                 'S'
         30        DO_ICALL                                         $13     
         31        TYPE_CHECK                                    4  ~14     $13
         32        BOOL                                             ~12     ~14
         33    > > JMPZ                                                     ~12, ->37
         34    >   FETCH_DIM_W                                      $15     !2, 'NR'
         35        ASSIGN_DIM                                               $15, !1
         36        OP_DATA                                                  !0
   15    37    > > RETURN                                                   null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.98 ms | 1012 KiB | 16 Q