I have an order form that uses the same name for each row item, an example below:
<input name="item['1']['stock_code']">
<input name="item['1']['quantity']">
<input name="item['2']['stock_code']">
<input name="item['2']['quantity']">
I am iterating over each of the $_POST item's like so:
$items = $_POST['item'];
foreach($items as $item){
$item_stock_code = $item['stock_code'];
$item_description = $item['description'];
$item_price_net = $item['sale_price'];
$item_quantity = $item['quantity'];
$item_notes = $item['order_notes'];
}
However, I am now receiving an error when trying to access each property of an undefined index.
An example of print_r($item) is below:
Array
(
['stock_code'] => PLN-10002J
['quantity'] => 2
['description'] => 5MM-20MM TRANSFER CENTRE PUNCH (PLN-10002J)
['sale_price'] => 24.35
['order_notes'] => testt
)
Where am I going wrong, trying to access the values of each item?
Notice: Undefined index: stock_codeis the error, along with the same for description, sale_price, quantity and order_notes.foreachloop?foreachloop