3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_del_invalid(&$a, $ikc = [], $ivc = []) { if(! empty($ikc) || ! empty($ivc)) { foreach ($a as $k => $v) { $treated_key = str_replace($ikc, '', $k); $treated_val = str_replace($ivc, '', $v); if($k !== $treated_key) { unset($a[$k]); $a[$treated_key] = $v; } if($v !== $treated_val) { $a[$treated_key] = $treated_val; } } } } $arr = [ 'a' => 'Letter A!', '`b`' => 'Letter B w/quotes...', ' c ' => 'Letter C w/spaces?', ' -_-`d`- _ - ' => 'Letter D w/all?!...' ]; $original_arr = $arr; $invalid_keys_chars = ['`',' ','_','-']; $invalid_vals_chars = ['!','?','.']; array_del_invalid($arr, $invalid_keys_chars, $invalid_vals_chars); var_export($arr); // only keys replacement $arr = $original_arr; array_del_invalid($arr, $invalid_keys_chars); var_export($arr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8LnSh
function name:  (null)
number of ops:  21
compiled vars:  !0 = $arr, !1 = $original_arr, !2 = $invalid_keys_chars, !3 = $invalid_vals_chars
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                   !0, <array>
   23     1        ASSIGN                                                   !1, !0
   24     2        ASSIGN                                                   !2, <array>
   25     3        ASSIGN                                                   !3, <array>
   26     4        INIT_FCALL                                               'array_del_invalid'
          5        SEND_REF                                                 !0
          6        SEND_VAR                                                 !2
          7        SEND_VAR                                                 !3
          8        DO_FCALL                                      0          
   27     9        INIT_FCALL                                               'var_export'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                                 
   30    12        ASSIGN                                                   !0, !1
   31    13        INIT_FCALL                                               'array_del_invalid'
         14        SEND_REF                                                 !0
         15        SEND_VAR                                                 !2
         16        DO_FCALL                                      0          
   32    17        INIT_FCALL                                               'var_export'
         18        SEND_VAR                                                 !0
         19        DO_ICALL                                                 
         20      > RETURN                                                   1

Function array_del_invalid:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 36
Branch analysis from position: 10
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 35
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 35
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 30
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 34
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 34
Branch analysis from position: 30
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
Branch analysis from position: 36
Branch analysis from position: 9
filename:       /in/8LnSh
function name:  array_del_invalid
number of ops:  37
compiled vars:  !0 = $a, !1 = $ikc, !2 = $ivc, !3 = $v, !4 = $k, !5 = $treated_key, !6 = $treated_val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
          2        RECV_INIT                                        !2      <array>
    3     3        ISSET_ISEMPTY_CV                                 ~7      !1
          4        BOOL_NOT                                         ~8      ~7
          5      > JMPNZ_EX                                         ~8      ~8, ->9
          6    >   ISSET_ISEMPTY_CV                                 ~9      !2
          7        BOOL_NOT                                         ~10     ~9
          8        BOOL                                             ~8      ~10
          9    > > JMPZ                                                     ~8, ->36
    4    10    > > FE_RESET_R                                       $11     !0, ->35
         11    > > FE_FETCH_R                                       ~12     $11, !3, ->35
         12    >   ASSIGN                                                   !4, ~12
    5    13        INIT_FCALL                                               'str_replace'
         14        SEND_VAR                                                 !1
         15        SEND_VAL                                                 ''
         16        SEND_VAR                                                 !4
         17        DO_ICALL                                         $14     
         18        ASSIGN                                                   !5, $14
    6    19        INIT_FCALL                                               'str_replace'
         20        SEND_VAR                                                 !2
         21        SEND_VAL                                                 ''
         22        SEND_VAR                                                 !3
         23        DO_ICALL                                         $16     
         24        ASSIGN                                                   !6, $16
    7    25        IS_NOT_IDENTICAL                                         !4, !5
         26      > JMPZ                                                     ~18, ->30
    8    27    >   UNSET_DIM                                                !0, !4
    9    28        ASSIGN_DIM                                               !0, !5
         29        OP_DATA                                                  !3
   11    30    >   IS_NOT_IDENTICAL                                         !3, !6
         31      > JMPZ                                                     ~20, ->34
   12    32    >   ASSIGN_DIM                                               !0, !5
         33        OP_DATA                                                  !6
    4    34    > > JMP                                                      ->11
         35    >   FE_FREE                                                  $11
   16    36    > > RETURN                                                   null

End of function array_del_invalid

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.16 ms | 1006 KiB | 17 Q