3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array( "action: Added; amount: 1; code: RNA1; name: Mens Organic T-shirt; colour: White; size: XL", "action: Subtracted; amount: 7; code: RNC1; name: Kids Basic T-shirt; colour: Denim Blue; size: 3-4y", "action: Added; amount: 20; code: RNV1; name: Gift Voucher; style: Mens; value: £20", ); $result = array_map(function($line) { return array_combine(...array_map(null, ...array_chunk(preg_split('/[:;]\s+/', $line), 2))); }, $arr); print_r($result);
Output for 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.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
Array ( [0] => Array ( [action] => Added [amount] => 1 [code] => RNA1 [name] => Mens Organic T-shirt [colour] => White [size] => XL ) [1] => Array ( [action] => Subtracted [amount] => 7 [code] => RNC1 [name] => Kids Basic T-shirt [colour] => Denim Blue [size] => 3-4y ) [2] => Array ( [action] => Added [amount] => 20 [code] => RNV1 [name] => Gift Voucher [style] => Mens [value] => £20 ) )

preferences:
72.37 ms | 409 KiB | 5 Q