3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 'checklist1' => 'major', 'result_audit1' => 1, 'checklist2' => 'minor', 'result_audit2' => 2, 'checklist3' => 'pico', 'result_audit3' => 3, 'checklist4' => 'goodpoints', 'result_audit4' => 4, 'submit' => 'Submit Now' ]; $result = []; foreach ($array as $k => $v) { if (sscanf($k, 'checklist%d', $integer)) { // isolate integer only on "checklist" keyed elements $result['checklist'][] = [ 'selected' => $v, 'result_audit' => $array["result_audit$integer"], 'origin' => $k ]; } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 21
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 21
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 20
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 20
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/aYY8E
function name:  (null)
number of ops:  26
compiled vars:  !0 = $array, !1 = $result, !2 = $v, !3 = $k, !4 = $integer
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   15     1        ASSIGN                                                   !1, <array>
   16     2      > FE_RESET_R                                       $7      !0, ->21
          3    > > FE_FETCH_R                                       ~8      $7, !2, ->21
          4    >   ASSIGN                                                   !3, ~8
   17     5        INIT_FCALL                                               'sscanf'
          6        SEND_VAR                                                 !3
          7        SEND_VAL                                                 'checklist%25d'
          8        SEND_REF                                                 !4
          9        DO_ICALL                                         $10     
         10      > JMPZ                                                     $10, ->20
   19    11    >   INIT_ARRAY                                       ~13     !2, 'selected'
   20    12        NOP                                                      
         13        FAST_CONCAT                                      ~14     'result_audit', !4
         14        FETCH_DIM_R                                      ~15     !0, ~14
         15        ADD_ARRAY_ELEMENT                                ~13     ~15, 'result_audit'
   21    16        ADD_ARRAY_ELEMENT                                ~13     !3, 'origin'
   18    17        FETCH_DIM_W                                      $11     !1, 'checklist'
         18        ASSIGN_DIM                                               $11
   21    19        OP_DATA                                                  ~13
   16    20    > > JMP                                                      ->3
         21    >   FE_FREE                                                  $7
   25    22        INIT_FCALL                                               'var_export'
         23        SEND_VAR                                                 !1
         24        DO_ICALL                                                 
         25      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.38 ms | 1012 KiB | 15 Q