3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '[{ "id": "5b2a4b0287bc2c082ebc2897", "test_name": "BSF", "test_type": "Pathology", "cost": "100" }, { "id": "5b2a4ac63db998081e7f6c97", "test_name": "Brain & PNS", "test_type": "Radiology", "cost": "1000" }, { "id": "5b2a4ac63db998081e22336c97", "test_name": "BPNS", "test_type": "Radiology", "cost": "1000" }, { "id": "5b2a4ac63db998081e22336c97", "test_name": "BPNS", "test_type": "Somethingelseology", "cost": "1000" }]'; $arr = json_decode($json,true); $type = array_column($arr, "test_type"); Foreach(array_unique($type) as $t){ $new[$t] = array_intersect_key($arr, array_intersect($type, [$t])); } extract($new); var_dump($Radiology, $Pathology, $Somethingelseology);
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 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(2) { [1]=> array(4) { ["id"]=> string(24) "5b2a4ac63db998081e7f6c97" ["test_name"]=> string(11) "Brain & PNS" ["test_type"]=> string(9) "Radiology" ["cost"]=> string(4) "1000" } [2]=> array(4) { ["id"]=> string(26) "5b2a4ac63db998081e22336c97" ["test_name"]=> string(4) "BPNS" ["test_type"]=> string(9) "Radiology" ["cost"]=> string(4) "1000" } } array(1) { [0]=> array(4) { ["id"]=> string(24) "5b2a4b0287bc2c082ebc2897" ["test_name"]=> string(3) "BSF" ["test_type"]=> string(9) "Pathology" ["cost"]=> string(3) "100" } } array(1) { [3]=> array(4) { ["id"]=> string(26) "5b2a4ac63db998081e22336c97" ["test_name"]=> string(4) "BPNS" ["test_type"]=> string(18) "Somethingelseology" ["cost"]=> string(4) "1000" } }
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:
192.25 ms | 408 KiB | 5 Q