将text和foreach键组合为数组键

How can you add text to an array key whilst also using the 'key' of a foreach loop.

For instance. I want to output each array item from one array into another with the keys 'price_0', 'price_1', 'price_2' and so on.

foreach($pricesArray as $key=>$value){
     $data['price_'$key']'] = $pricesArray[$key];
}

Thanks

You need to append it using the concatenate operator and remove the unneccessary quote and a square bracket.

foreach($pricesArray as $key=>$value){
     $data['price_'.$key] = $pricesArray[$key];
     //            ^ 
}