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, ), ) ); $count = array_sum(array_column($prices['options'], 'count')); $minmax = array_map( function($option){ $split=explode('_',$option['value']); return [(int)$split[0],(int)$split[1]]; }, $prices['options'] ); $min=min(array_column($minmax,0)); $max=max(array_column($minmax,1)); $prices['options'] = [ 'label' => $min . '-' . $max, 'value' => $min . '_' . $max, 'count' => $count ]; echo print_r($prices,true);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GqI2U
function name:  (null)
number of ops:  48
compiled vars:  !0 = $prices, !1 = $count, !2 = $minmax, !3 = $min, !4 = $max
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, <array>
   34     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
   35    10        INIT_FCALL                                                   'array_map'
   36    11        DECLARE_LAMBDA_FUNCTION                              ~10     [0]
   39    12        SEND_VAL                                                     ~10
   40    13        FETCH_DIM_R                                          ~11     !0, 'options'
         14        SEND_VAL                                                     ~11
   35    15        DO_ICALL                                             $12     
         16        ASSIGN                                                       !2, $12
   42    17        INIT_FCALL                                                   'min'
         18        INIT_FCALL                                                   'array_column'
         19        SEND_VAR                                                     !2
         20        SEND_VAL                                                     0
         21        DO_ICALL                                             $14     
         22        SEND_VAR                                                     $14
         23        DO_ICALL                                             $15     
         24        ASSIGN                                                       !3, $15
   43    25        INIT_FCALL                                                   'max'
         26        INIT_FCALL                                                   'array_column'
         27        SEND_VAR                                                     !2
         28        SEND_VAL                                                     1
         29        DO_ICALL                                             $17     
         30        SEND_VAR                                                     $17
         31        DO_ICALL                                             $18     
         32        ASSIGN                                                       !4, $18
   45    33        CONCAT                                               ~21     !3, '-'
         34        CONCAT                                               ~22     ~21, !4
         35        INIT_ARRAY                                           ~23     ~22, 'label'
   46    36        CONCAT                                               ~24     !3, '_'
         37        CONCAT                                               ~25     ~24, !4
         38        ADD_ARRAY_ELEMENT                                    ~23     ~25, 'value'
   47    39        ADD_ARRAY_ELEMENT                                    ~23     !1, 'count'
   44    40        ASSIGN_DIM                                                   !0, 'options'
   47    41        OP_DATA                                                      ~23
   50    42        INIT_FCALL                                                   'print_r'
         43        SEND_VAR                                                     !0
         44        SEND_VAL                                                     <true>
         45        DO_ICALL                                             $26     
         46        ECHO                                                         $26
         47      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GqI2U
function name:  {closure:/in/GqI2U:36}
number of ops:  15
compiled vars:  !0 = $option, !1 = $split
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   36     0  E >   RECV                                                 !0      
   37     1        INIT_FCALL                                                   'explode'
          2        SEND_VAL                                                     '_'
          3        FETCH_DIM_R                                          ~2      !0, 'value'
          4        SEND_VAL                                                     ~2
          5        DO_ICALL                                             $3      
          6        ASSIGN                                                       !1, $3
   38     7        FETCH_DIM_R                                          ~5      !1, 0
          8        CAST                                              4  ~6      ~5
          9        INIT_ARRAY                                           ~7      ~6
         10        FETCH_DIM_R                                          ~8      !1, 1
         11        CAST                                              4  ~9      ~8
         12        ADD_ARRAY_ELEMENT                                    ~7      ~9
         13      > RETURN                                                       ~7
   39    14*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
146.23 ms | 2073 KiB | 20 Q