3v4l.org

run code in 300+ PHP versions simultaneously
<?php $raw = <<< 'TEXT' FIRSTNAME=firstname NAME=lastname STREET=street adress CITY=cityname ZIP=zipcode COUNTRY=country ISOCOUNTRY=US EMAIL=email@domene.com MOBILENO=123456789 USERNO=somenumber [PRODUCT] QTY=2 ALPROJECTID=1123208 PRICE=134,00 DESCRIPTION=product1 ARTNO=1 [PRODUCT] QTY=1 ALPROJECTID=9563214 PRICE=64,00 DESCRIPTION=product2 ARTNO=2 TEXT; //replace [PRODUCT] with [PRODUCT_1], [PRODUCT_2]... $raw = preg_replace_callback( '/\[PRODUCT\]/', function() {static $i=0; return '[PRODUCT_'.$i++.']';} ,$raw, -1, $count); //parse string into an array $data = parse_ini_string($raw,true); //extract the products into their own array. This assumes that //[PRODUCT] sections are always at the end of the file $products = array_values(array_splice($data,$count*-1)); //Build the final array $data = $data + ['PRODUCTS'=>$products]; echo "There are $count products \n\n"; print_r($data);

preferences:
34.15 ms | 402 KiB | 5 Q