<?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);
You have javascript disabled. You will not be able to edit any code.