3v4l.org

run code in 300+ PHP versions simultaneously
<?php //$contents = file_get_contents($path); $contents = "sku-vendeur quantit prix id-produit 10000 3 51,95 B00E3LV204 10002 3 85,96 B00PE9ZC1E 100024 3 345,73 B01LWMZ33O 100031 3 88,22 B018NOSAZ6"; preg_match_all("/^(.*?)\s+(.*?)\s+(.*?)\s+(.*?)$/m", $contents, $arr); unset($arr[0]); // remove 0 since we don't need it. $keys = array_column($arr, 0); foreach($arr[1] as $key2 => $val){ if($key2 != 0){ $new[] = array_combine($keys,array_column($arr, $key2)); } } var_dump($new);

preferences:
28.48 ms | 407 KiB | 5 Q