3v4l.org

run code in 500+ PHP versions simultaneously
<?php $prices = array( 'label' => 'Price', 'count' => 5, 'attribute_code' => 'price', 'options' => array( 0 => array( 'label' => '0-100', 'value' => '0_100', 'count' => 2208, ), 1 => array( 'label' => '100-200', 'value' => '100_200', 'count' => 338, ), 2 => array( 'label' => '200-300', 'value' => '200_300', 'count' => 16, ), 3 => array( 'label' => '300-400', 'value' => '300_400', 'count' => 1, ), 4 => array( 'label' => '400-500', 'value' => '400_500', 'count' => 1, ), 5 => array( 'label' => '100-600', 'value' => '100_600', 'count' => 1, ), ) ); $counts = array_sum(array_column($prices['options'], 'count')); $values = []; foreach ($prices['options'] as $priceOption) { [$values[], $values[]] = explode('_', $priceOption['value']); } $lower = min($values); $upper = max($values); $prices['options'] = [ 'label' => $lower . '-' . $upper, 'value' => $lower . '_' . $upper, 'count' => $counts, ]; var_export($prices['options']);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 27
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 27
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/a8BCL
function name:  (null)
number of ops:  50
compiled vars:  !0 = $prices, !1 = $counts, !2 = $values, !3 = $priceOption, !4 = $lower, !5 = $upper
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   41     1        INIT_FCALL                                                   'array_sum'
          2        INIT_FCALL                                                   'array_column'
          3        FETCH_DIM_R                                          ~7      !0, 'options'
          4        SEND_VAL                                                     ~7
          5        SEND_VAL                                                     'count'
          6        DO_ICALL                                             $8      
          7        SEND_VAR                                                     $8
          8        DO_ICALL                                             $9      
          9        ASSIGN                                                       !1, $9
   43    10        ASSIGN                                                       !2, <array>
   44    11        FETCH_DIM_R                                          ~12     !0, 'options'
         12      > FE_RESET_R                                           $13     ~12, ->27
         13    > > FE_FETCH_R                                                   $13, !3, ->27
   45    14    >   INIT_FCALL                                                   'explode'
         15        SEND_VAL                                                     '_'
         16        FETCH_DIM_R                                          ~14     !3, 'value'
         17        SEND_VAL                                                     ~14
         18        DO_ICALL                                             $15     
         19        FETCH_LIST_R                                         $16     $15, 0
         20        ASSIGN_DIM                                                   !2
         21        OP_DATA                                                      $16
         22        FETCH_LIST_R                                         $18     $15, 1
         23        ASSIGN_DIM                                                   !2
         24        OP_DATA                                                      $18
         25        FREE                                                         $15
   44    26      > JMP                                                          ->13
         27    >   FE_FREE                                                      $13
   47    28        INIT_FCALL                                                   'min'
         29        SEND_VAR                                                     !2
         30        DO_ICALL                                             $20     
         31        ASSIGN                                                       !4, $20
   48    32        INIT_FCALL                                                   'max'
         33        SEND_VAR                                                     !2
         34        DO_ICALL                                             $22     
         35        ASSIGN                                                       !5, $22
   51    36        CONCAT                                               ~25     !4, '-'
         37        CONCAT                                               ~26     ~25, !5
         38        INIT_ARRAY                                           ~27     ~26, 'label'
   52    39        CONCAT                                               ~28     !4, '_'
         40        CONCAT                                               ~29     ~28, !5
         41        ADD_ARRAY_ELEMENT                                    ~27     ~29, 'value'
   53    42        ADD_ARRAY_ELEMENT                                    ~27     !1, 'count'
   50    43        ASSIGN_DIM                                                   !0, 'options'
   53    44        OP_DATA                                                      ~27
   56    45        INIT_FCALL                                                   'var_export'
         46        FETCH_DIM_R                                          ~30     !0, 'options'
         47        SEND_VAL                                                     ~30
         48        DO_ICALL                                                     
         49      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
163.59 ms | 2053 KiB | 19 Q