3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr1 = array( 0 => ['product_type'=>'manufacturer','id'=>1], 1 => ['product_type'=>'manufacturer','id'=>2], 2 => ['product_type'=>'seller'], 3 => ['product_type'=>'seller'], 4 => ['product_type'=>'seller'], 5 => ['product_type'=>'seller'], 6 => ['product_type'=>'seller'], 7 => ['product_type'=>'manufacturer','id'=>3], ); $manuCounter = 0; $sellerCounter = 0; $result = []; foreach ($arr1 as $row) { if ($row['product_type'] === 'manufacturer') { $manuCounter += 4; $result[$manuCounter] = $row; } else { ++$sellerCounter; if (!($sellerCounter % 4)) { ++$sellerCounter; } $result[$sellerCounter] = $row; } } ksort($result); var_export(array_values($result));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 21
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 21
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 13
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 18
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 18
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/uINFm
function name:  (null)
number of ops:  32
compiled vars:  !0 = $arr1, !1 = $manuCounter, !2 = $sellerCounter, !3 = $result, !4 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   14     1        ASSIGN                                                   !1, 0
   15     2        ASSIGN                                                   !2, 0
   16     3        ASSIGN                                                   !3, <array>
   17     4      > FE_RESET_R                                       $9      !0, ->21
          5    > > FE_FETCH_R                                               $9, !4, ->21
   18     6    >   FETCH_DIM_R                                      ~10     !4, 'product_type'
          7        IS_IDENTICAL                                             ~10, 'manufacturer'
          8      > JMPZ                                                     ~11, ->13
   19     9    >   ASSIGN_OP                                     1          !1, 4
   20    10        ASSIGN_DIM                                               !3, !1
         11        OP_DATA                                                  !4
         12      > JMP                                                      ->20
   22    13    >   PRE_INC                                                  !2
   23    14        MOD                                              ~15     !2, 4
         15        BOOL_NOT                                         ~16     ~15
         16      > JMPZ                                                     ~16, ->18
   24    17    >   PRE_INC                                                  !2
   26    18    >   ASSIGN_DIM                                               !3, !2
         19        OP_DATA                                                  !4
   17    20    > > JMP                                                      ->5
         21    >   FE_FREE                                                  $9
   29    22        INIT_FCALL                                               'ksort'
         23        SEND_REF                                                 !3
         24        DO_ICALL                                                 
   30    25        INIT_FCALL                                               'var_export'
         26        INIT_FCALL                                               'array_values'
         27        SEND_VAR                                                 !3
         28        DO_ICALL                                         $20     
         29        SEND_VAR                                                 $20
         30        DO_ICALL                                                 
         31      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.67 ms | 1401 KiB | 19 Q