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, ), ) ); $counts = array_sum(array_column($prices['options'], 'count')); $values = array_column($prices['options'], 'value'); array_multisort($values, SORT_ASC, SORT_NATURAL); $lowest = explode('_', $values[array_key_first($values)])[0]; $highest = explode('_', $values[array_key_last($values)])[1]; $prices['options'] = [ 'label' => $lowest . '-' . $highest, 'value' => $lowest . '_' . $highest, 'count' => $counts ]; var_export($prices['options']);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iTbcq
function name:  (null)
number of ops:  55
compiled vars:  !0 = $prices, !1 = $counts, !2 = $values, !3 = $lowest, !4 = $highest
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   36     1        INIT_FCALL                                                   'array_sum'
          2        INIT_FCALL                                                   'array_column'
          3        FETCH_DIM_R                                          ~6      !0, 'options'
          4        SEND_VAL                                                     ~6
          5        SEND_VAL                                                     'count'
          6        DO_ICALL                                             $7      
          7        SEND_VAR                                                     $7
          8        DO_ICALL                                             $8      
          9        ASSIGN                                                       !1, $8
   38    10        INIT_FCALL                                                   'array_column'
         11        FETCH_DIM_R                                          ~10     !0, 'options'
         12        SEND_VAL                                                     ~10
         13        SEND_VAL                                                     'value'
         14        DO_ICALL                                             $11     
         15        ASSIGN                                                       !2, $11
   39    16        INIT_FCALL                                                   'array_multisort'
         17        SEND_REF                                                     !2
         18        SEND_VAL                                                     4
         19        SEND_VAL                                                     6
         20        DO_ICALL                                                     
   41    21        INIT_FCALL                                                   'explode'
         22        SEND_VAL                                                     '_'
         23        INIT_FCALL                                                   'array_key_first'
         24        SEND_VAR                                                     !2
         25        DO_ICALL                                             $14     
         26        FETCH_DIM_R                                          ~15     !2, $14
         27        SEND_VAL                                                     ~15
         28        DO_ICALL                                             $16     
         29        FETCH_DIM_R                                          ~17     $16, 0
         30        ASSIGN                                                       !3, ~17
   42    31        INIT_FCALL                                                   'explode'
         32        SEND_VAL                                                     '_'
         33        INIT_FCALL                                                   'array_key_last'
         34        SEND_VAR                                                     !2
         35        DO_ICALL                                             $19     
         36        FETCH_DIM_R                                          ~20     !2, $19
         37        SEND_VAL                                                     ~20
         38        DO_ICALL                                             $21     
         39        FETCH_DIM_R                                          ~22     $21, 1
         40        ASSIGN                                                       !4, ~22
   46    41        CONCAT                                               ~25     !3, '-'
         42        CONCAT                                               ~26     ~25, !4
         43        INIT_ARRAY                                           ~27     ~26, 'label'
   47    44        CONCAT                                               ~28     !3, '_'
         45        CONCAT                                               ~29     ~28, !4
         46        ADD_ARRAY_ELEMENT                                    ~27     ~29, 'value'
   48    47        ADD_ARRAY_ELEMENT                                    ~27     !1, 'count'
   45    48        ASSIGN_DIM                                                   !0, 'options'
   48    49        OP_DATA                                                      ~27
   51    50        INIT_FCALL                                                   'var_export'
         51        FETCH_DIM_R                                          ~30     !0, 'options'
         52        SEND_VAL                                                     ~30
         53        DO_ICALL                                                     
         54      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
176.22 ms | 2046 KiB | 20 Q