3v4l.org

run code in 300+ PHP versions simultaneously
<?php $cart_array = json_decode('{ "items":[ { "count":"1", "cart_id":123, "plu":"TP16", "description":"Bag" }, { "count":1, "cart_id":1234, "plu":"DISCT10", "description":"10% Discount" } ], "total":9.9, "discount_total":9.9 }', true); $cart_array['items'] = array_column($cart_array['items'], NULL, 'cart_id'); Var_dump($cart_array);
Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0
array(3) { ["items"]=> array(2) { [123]=> array(4) { ["count"]=> string(1) "1" ["cart_id"]=> int(123) ["plu"]=> string(4) "TP16" ["description"]=> string(3) "Bag" } [1234]=> array(4) { ["count"]=> int(1) ["cart_id"]=> int(1234) ["plu"]=> string(7) "DISCT10" ["description"]=> string(12) "10% Discount" } } ["total"]=> float(9.9) ["discount_total"]=> float(9.9) }
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
190.03 ms | 408 KiB | 5 Q