I would split the names into separate arrays like this, after that it should be easy to populate the drop-down lists as needed:
$product_names = $option_names = array(); foreach ($products as $index => $product) { $product_names[$index] = $product['name']; foreach ($product['option_value'] as $option) { $option_names[$index][] = $option['name']; } }
If you need a product name for array index 0, you must use $ product_names [0] (string), and the option names for this product can be found from $ option_names [0] (array).
The code above does not care about the existing identifier, so if you need them for the form, you need to expand the code a bit.
source share