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']);
Output for 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.4, 8.3.6 - 8.3.30, 8.4.1 - 8.4.21, 8.5.0 - 8.5.6
array ( 'label' => '0-600', 'value' => '0_600', 'count' => 2565, )
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 array ( 'label' => '0-600', 'value' => '0_600', 'count' => 2565, )
Output for 7.0.33
Parse error: syntax error, unexpected '=' in /in/a8BCL on line 45
Process exited with code 255.
Output for 5.6.40
Fatal error: Cannot use [] for reading in /in/a8BCL on line 45
Process exited with code 255.

preferences:
76.75 ms | 1412 KiB | 4 Q