3v4l.org

run code in 300+ PHP versions simultaneously
<?php $_POST = ['VAL0' => 'TESTING', 'UNIT0' => '99', 'VAL1' => 'TESTING1', 'UNITS1' => '88']; $bulkProducts = array(); foreach ($_POST as $key => $value) { if (strpos($key, "VAL")===0) { $val= $value; } if (strpos($key, "UNIT")===0) { $newunits= $value; } if (isset($val,$newunits)) { $products = array(); $products = array( 'VAL' => $val, 'UNITS' =>$newunits ); array_push($bulkProducts,$products); } } print_r($bulkProducts);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 35
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 35
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 14
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 21
Branch analysis from position: 20
2 jumps found. (Code = 46) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 34
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 34
Branch analysis from position: 25
Branch analysis from position: 21
Branch analysis from position: 14
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
filename:       /in/iC48Y
function name:  (null)
number of ops:  40
compiled vars:  !0 = $bulkProducts, !1 = $value, !2 = $key, !3 = $val, !4 = $newunits, !5 = $products
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   FETCH_W                      global              $6      '_POST'
          1        ASSIGN                                                   $6, <array>
    4     2        ASSIGN                                                   !0, <array>
    5     3        FETCH_R                      global              ~9      '_POST'
          4      > FE_RESET_R                                       $10     ~9, ->35
          5    > > FE_FETCH_R                                       ~11     $10, !1, ->35
          6    >   ASSIGN                                                   !2, ~11
    6     7        INIT_FCALL                                               'strpos'
          8        SEND_VAR                                                 !2
          9        SEND_VAL                                                 'VAL'
         10        DO_ICALL                                         $13     
         11        IS_IDENTICAL                                             $13, 0
         12      > JMPZ                                                     ~14, ->14
    7    13    >   ASSIGN                                                   !3, !1
    9    14    >   INIT_FCALL                                               'strpos'
         15        SEND_VAR                                                 !2
         16        SEND_VAL                                                 'UNIT'
         17        DO_ICALL                                         $16     
         18        IS_IDENTICAL                                             $16, 0
         19      > JMPZ                                                     ~17, ->21
   10    20    >   ASSIGN                                                   !4, !1
   12    21    >   ISSET_ISEMPTY_CV                                 ~19     !3
         22      > JMPZ_EX                                          ~19     ~19, ->25
         23    >   ISSET_ISEMPTY_CV                                 ~20     !4
         24        BOOL                                             ~19     ~20
         25    > > JMPZ                                                     ~19, ->34
   13    26    >   ASSIGN                                                   !5, <array>
   15    27        INIT_ARRAY                                       ~22     !3, 'VAL'
   16    28        ADD_ARRAY_ELEMENT                                ~22     !4, 'UNITS'
   14    29        ASSIGN                                                   !5, ~22
   18    30        INIT_FCALL                                               'array_push'
         31        SEND_REF                                                 !0
         32        SEND_VAR                                                 !5
         33        DO_ICALL                                                 
    5    34    > > JMP                                                      ->5
         35    >   FE_FREE                                                  $10
   21    36        INIT_FCALL                                               'print_r'
         37        SEND_VAR                                                 !0
         38        DO_ICALL                                                 
         39      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
185.51 ms | 1400 KiB | 19 Q