拉出并存储个人内容

I have been told that I can pull out individual content values from a posted value and then put them in a variable:

$Product .= "${item_id}-${length}-${Category}-${each_item['quantity']},";

The outcome of the variable would be something like: women_boot-16 Inch-Virgin_boots-3 My product ID in this case is "women_boot". In my form, I execute $product into the value:

echo = '<input type="hidden" name="custom" value="' . $Product . '">';

In the page, I post to I have: $product_id_string = $_POST['custom']; which would become $product_id_string = $_POST['women_boot-16 Inch-Virgin_boots-3,'];


I now want to pull each piece of content out from the post such that I can form them like this:

$id   =  women_boot
$length = 16 Inch
$type = Virgin_boots
$amount = 3

I have tried the following code, but it only works if I have one through three. How can I make it works for all my values?

$product_id_string = rtrim($product_id_string, ","); // remove last comma
$id_str_array = explode(",", $product_id_string); // Uses Comma(,) as delimiter(break point)
$fullAmount = 0;
foreach ($id_str_array as $key => $value) {
$id_quantity_pair = explode("-", $value);
$product_id = $id_quantity_pair[0]; // Get the product ID

UPDATE I need to pull out this content in to make it work:

$stmt2 = $conn->prepare("
    SELECT bb.Price FROM Product aa, Itemised_Product bb, Category cc 
    WHERE aa.Sef = :product_id
    bb.ItemID = :length
    AND 
    cc.CatID = :Category LIMIT 1");
    $stmt2->bindParam('product_id',$product_id);
    $stmt2->bindParam('length',$length); 
    $stmt2->bindParam('Category',$category);
$product_id_string = "men_coat-16 Inch-Virgin_boots-3,women_boot-16 Inch-Virgin_boots-1,";
$product_id_string = rtrim($product_id_string, ","); // remove last comma
$id_str_array = explode(",", $product_id_string); // Uses Comma(,) as delimiter(break point)
$items = array();
foreach ($id_str_array as $key => $value) {
    $id_quantity_pair = explode("-", $value);
    $items[$key]['item_id'] = $id_quantity_pair[0];
    $items[$key]['length'] = $id_quantity_pair[1];
    $items[$key]['category'] = $id_quantity_pair[2];
    $items[$key]['quantity'] = $id_quantity_pair[3];
}
print_r($items);

You can prepare your query as follows:

$stmt2 = $conn->prepare("
    SELECT bb.Price FROM Product aa, Itemised_Product bb, Category cc 
    WHERE aa.Sef = :product_id
    bb.ItemID = :length
    AND 
    cc.CatID = :Category LIMIT 1");
    $stmt2->bindParam('product_id',$item[0]['item_id']);
    $stmt2->bindParam('length',$item[0]['length']); 
    $stmt2->bindParam('Category',$item[0]['category']);