3v4l.org

run code in 500+ 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 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/KOPhW
function name:  {closure:/in/KOPhW:5}
number of ops:  9
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        FRAMELESS_ICALL_2                strpos              ~3      !1, 'C'
          4        TYPE_CHECK                                      1018          ~3
          5      > JMPZ                                                         ~4, ->8
          6    >   ASSIGN_DIM                                                   !2, !1
          7        OP_DATA                                                      !0
    7     8    > > 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 = 6, Position 2 = 9
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
2 jumps found. (Code = 46) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 25
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
Branch analysis from position: 21
Branch analysis from position: 15
Branch analysis from position: 9
filename:       /in/KOPhW
function name:  {closure:/in/KOPhW:11}
number of ops:  26
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        FRAMELESS_ICALL_2                strpos              ~3      !1, 'C'
          4        TYPE_CHECK                                      1018          ~3
          5      > JMPZ                                                         ~4, ->9
          6    >   FETCH_DIM_W                                          $5      !2, 'C'
          7        ASSIGN_DIM                                                   $5, !1
          8        OP_DATA                                                      !0
   13     9    >   FRAMELESS_ICALL_2                strpos              ~7      !1, 'S'
         10        TYPE_CHECK                                      1018          ~7
         11      > JMPZ                                                         ~8, ->15
         12    >   FETCH_DIM_W                                          $9      !2, 'S'
         13        ASSIGN_DIM                                                   $9, !1
         14        OP_DATA                                                      !0
   14    15    >   FRAMELESS_ICALL_2                strpos              ~11     !1, 'C'
         16        TYPE_CHECK                                        4  ~12     ~11
         17      > JMPZ_EX                                              ~12     ~12, ->21
         18    >   FRAMELESS_ICALL_2                strpos              ~13     !1, 'S'
         19        TYPE_CHECK                                        4  ~14     ~13
         20        BOOL                                                 ~12     ~14
         21    > > JMPZ                                                         ~12, ->25
         22    >   FETCH_DIM_W                                          $15     !2, 'NR'
         23        ASSIGN_DIM                                                   $15, !1
         24        OP_DATA                                                      !0
   15    25    > > RETURN                                                       null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
157.76 ms | 2041 KiB | 15 Q