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('_', reset($values))[0] ?? ''; $highest = explode('_', end($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/PmXg3
function name:  (null)
number of ops:  57
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                                                     
   40    21        INIT_FCALL                                                   'explode'
         22        SEND_VAL                                                     '_'
         23        INIT_FCALL                                                   'reset'
         24        SEND_REF                                                     !2
         25        DO_ICALL                                             $14     
         26        SEND_VAR                                                     $14
         27        DO_ICALL                                             $15     
         28        FETCH_DIM_IS                                         ~16     $15, 0
         29        COALESCE                                             ~17     ~16
         30        QM_ASSIGN                                            ~17     ''
         31        ASSIGN                                                       !3, ~17
   41    32        INIT_FCALL                                                   'explode'
         33        SEND_VAL                                                     '_'
         34        INIT_FCALL                                                   'end'
         35        SEND_REF                                                     !2
         36        DO_ICALL                                             $19     
         37        SEND_VAR                                                     $19
         38        DO_ICALL                                             $20     
         39        FETCH_DIM_IS                                         ~21     $20, 1
         40        COALESCE                                             ~22     ~21
         41        QM_ASSIGN                                            ~22     ''
         42        ASSIGN                                                       !4, ~22
   45    43        CONCAT                                               ~25     !3, '-'
         44        CONCAT                                               ~26     ~25, !4
         45        INIT_ARRAY                                           ~27     ~26, 'label'
   46    46        CONCAT                                               ~28     !3, '_'
         47        CONCAT                                               ~29     ~28, !4
         48        ADD_ARRAY_ELEMENT                                    ~27     ~29, 'value'
   47    49        ADD_ARRAY_ELEMENT                                    ~27     !1, 'count'
   44    50        ASSIGN_DIM                                                   !0, 'options'
   47    51        OP_DATA                                                      ~27
   50    52        INIT_FCALL                                                   'var_export'
         53        FETCH_DIM_R                                          ~30     !0, 'options'
         54        SEND_VAL                                                     ~30
         55        DO_ICALL                                                     
         56      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
162.4 ms | 2046 KiB | 20 Q