I have a form such as the below:
<form name="basketSelectionForm" action="processBasket.php" method="POST">
<div id="tabs-1">
<table cellpadding="10" cellspacing="10" width="inherit">
<tr>
<td><img alt="itemNameb" src="images/itemName.jpg" width="70px" height="70px"/></td>
<td>Qty. <input value="0" id="itemName" name="basket[itemName]" type="text" style="width:40px;"/> </td>
<td><img alt="itemName" src="images/itemName.jpg" width="70px" height="70px"/></td>
<td>Qty. <input value="0" id="itemName" name="basket[itemName]" type="text" style="width:40px;"/></td>
Now when I go to second page to look at the entries of the array, I do this:
<?php
$itemsBasket = array( );
$itemsBasket = $_POST['basket'];
echo "<h1>The Items Are...</h1><br>";
//print_r($itemsBasket);
foreach ($itemsBasket as $value)
{
if($value > 0){
echo $value . "<br>";
}
}
?>
This will print the value at the indexes of the array...but I need to store the name of the index so lets say the item is chocolate and value of 12. I want to extract that index name from array to store it in variable and then assign value to that variable...
Any way I can do that? right now I get only the value while iterating...
Thanks for help and sorry if question isn't clear I will help explain better if so...
UPDATE: this is the unexpected output....
whitethoab: Array woolthoab: 22 shemag: 22 undershirt: 1 serwalthoab: 22 socks: 12
and this is the definition of the element showing as two dimensional array...
<td><img alt="White Thoab" src="images/whitethoub.jpg" width="70px" height="70px"/></td>
<td>Qty. <input value="0" id="whitethoab" name="basket[whitethoab]" type="text" style="width:40px;"/> </td>