3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ "foo" => "no", "foo_contact_firstname" => "Mark", "foo_email" => "mark@gmail.com", "foo_address1" => "91", "foo_address2" => "old road", "foo_bill" => "no", "bar" => "yes", "bar_contact_lastname" => null, "bar_telephone" => null, "bar_email" => null, "bar_address1" => null, "bar_address2" => null, "bar_address3" => null, "bar_address4" => null, "bar_address5" => null, "bar_postcode" => null, "register_contact_firstname" => null, "register_contact_lastname" => null, "register_telephone" => null, "register_email" => null, "register_address1" => null, "register_address2" => null, "register_address3" => null, "register_address4" => null, "register_address5" => null, "register_postcode" => null, ]; $test = array_filter($array, function($key) { if( ($x_pos = strpos($key, 'foo')) !== FALSE ){ return substr($key, $x_pos + 1); } }, ARRAY_FILTER_USE_KEY ); var_dump($test);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Zab7D
function name:  (null)
number of ops:  12
compiled vars:  !0 = $array, !1 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   33     1        INIT_FCALL                                               'array_filter'
          2        SEND_VAR                                                 !0
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FZab7D%3A33%240'
   38     4        SEND_VAL                                                 ~3
          5        SEND_VAL                                                 2
          6        DO_ICALL                                         $4      
   33     7        ASSIGN                                                   !1, $4
   41     8        INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FZab7D%3A33%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Zab7D
function name:  {closure}
number of ops:  15
compiled vars:  !0 = $key, !1 = $x_pos
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
   34     1        INIT_FCALL                                               'strpos'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 'foo'
          4        DO_ICALL                                         $2      
          5        ASSIGN                                           ~3      !1, $2
          6        TYPE_CHECK                                  1018          ~3
          7      > JMPZ                                                     ~4, ->14
   35     8    >   INIT_FCALL                                               'substr'
          9        SEND_VAR                                                 !0
         10        ADD                                              ~5      !1, 1
         11        SEND_VAL                                                 ~5
         12        DO_ICALL                                         $6      
         13      > RETURN                                                   $6
   38    14    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FZab7D%3A33%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.13 ms | 1396 KiB | 21 Q