3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = ['user_firstname' => 'Jack', 'user_lastname' => 'Smith', 'user_address_1' => '123']; $data = []; foreach($array1 as $key=>$value){ if(strpos($key, "_") !== false){ if(strstr($key, 'firstname') === 'firstname'){ $data['firstname'] = $value; } if(strstr($key, 'lastname') === 'lastname'){ $data['lastname'] = $value; } if(strstr($key, 'address_1') === 'address_1'){ $data['address_1'] = $value; } // $data['firstname'] = strstr($key, 'firstname') === 'firstname' ? $value : null; } } print_r($data);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 36
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 36
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 35
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 27
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 35
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 35
Branch analysis from position: 27
Branch analysis from position: 19
Branch analysis from position: 35
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
filename:       /in/Ll01Q
function name:  (null)
number of ops:  41
compiled vars:  !0 = $array1, !1 = $data, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    5     2      > FE_RESET_R                                       $6      !0, ->36
          3    > > FE_FETCH_R                                       ~7      $6, !2, ->36
          4    >   ASSIGN                                                   !3, ~7
    6     5        INIT_FCALL                                               'strpos'
          6        SEND_VAR                                                 !3
          7        SEND_VAL                                                 '_'
          8        DO_ICALL                                         $9      
          9        TYPE_CHECK                                  1018          $9
         10      > JMPZ                                                     ~10, ->35
    8    11    >   INIT_FCALL                                               'strstr'
         12        SEND_VAR                                                 !3
         13        SEND_VAL                                                 'firstname'
         14        DO_ICALL                                         $11     
         15        IS_IDENTICAL                                             $11, 'firstname'
         16      > JMPZ                                                     ~12, ->19
    9    17    >   ASSIGN_DIM                                               !1, 'firstname'
         18        OP_DATA                                                  !2
   12    19    >   INIT_FCALL                                               'strstr'
         20        SEND_VAR                                                 !3
         21        SEND_VAL                                                 'lastname'
         22        DO_ICALL                                         $14     
         23        IS_IDENTICAL                                             $14, 'lastname'
         24      > JMPZ                                                     ~15, ->27
   13    25    >   ASSIGN_DIM                                               !1, 'lastname'
         26        OP_DATA                                                  !2
   16    27    >   INIT_FCALL                                               'strstr'
         28        SEND_VAR                                                 !3
         29        SEND_VAL                                                 'address_1'
         30        DO_ICALL                                         $17     
         31        IS_IDENTICAL                                             $17, 'address_1'
         32      > JMPZ                                                     ~18, ->35
   17    33    >   ASSIGN_DIM                                               !1, 'address_1'
         34        OP_DATA                                                  !2
    5    35    > > JMP                                                      ->3
         36    >   FE_FREE                                                  $6
   23    37        INIT_FCALL                                               'print_r'
         38        SEND_VAR                                                 !1
         39        DO_ICALL                                                 
         40      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.2 ms | 1405 KiB | 19 Q