3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = 'Created:2021-03-02,Tracks:1,Created:2021-02-23,Tracks:3,Created:2021-02-20,Tracks:4,Created:2021-02-16,Tracks:41,Created:2021-02-06,Tracks:1,Created:2021-02-02,Tracks:3,Created:2021-02-01,Tracks:2,Created:2021-01-29,Tracks:1,Created:2021-01-22,Tracks:1,Created:2021-01-19,Tracks:1,Created:2021-01-15,Tracks:1,Created:2021-01-14,Tracks:1,Created:2021-01-13,Tracks:1 '; $arr = explode(',', $str); $finalArray = []; foreach($arr as $ar){ $againExplode = explode(':',$ar); $finalArray[$againExplode[0]][] = $againExplode[1]; } print_r($finalArray);
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Array ( [Created] => Array ( [0] => 2021-03-02 [1] => 2021-02-23 [2] => 2021-02-20 [3] => 2021-02-16 [4] => 2021-02-06 [5] => 2021-02-02 [6] => 2021-02-01 [7] => 2021-01-29 [8] => 2021-01-22 [9] => 2021-01-19 [10] => 2021-01-15 [11] => 2021-01-14 [12] => 2021-01-13 ) [Tracks] => Array ( [0] => 1 [1] => 3 [2] => 4 [3] => 41 [4] => 1 [5] => 3 [6] => 2 [7] => 1 [8] => 1 [9] => 1 [10] => 1 [11] => 1 [12] => 1 ) )
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 ( [Created] => Array ( [0] => 2021-03-02 [1] => 2021-02-23 [2] => 2021-02-20 [3] => 2021-02-16 [4] => 2021-02-06 [5] => 2021-02-02 [6] => 2021-02-01 [7] => 2021-01-29 [8] => 2021-01-22 [9] => 2021-01-19 [10] => 2021-01-15 [11] => 2021-01-14 [12] => 2021-01-13 ) [Tracks] => Array ( [0] => 1 [1] => 3 [2] => 4 [3] => 41 [4] => 1 [5] => 3 [6] => 2 [7] => 1 [8] => 1 [9] => 1 [10] => 1 [11] => 1 [12] => 1 ) )

preferences:
148.29 ms | 403 KiB | 153 Q