I am still trying to understand how the php foreach loop works with accessing certain parts of it. I have an array setup like this:
$product = Array
(
[SX- Light weight] => Array
(
[bronze] => 4
[silver] => 5
[gold] => 6
)
[SS- Light weight] => Array
(
[bronze] => 4
[silver] => 5
[gold] => 6
)
)
I have a foreach loop set up like so:
foreach ($product as $name => $value) {
# code...
echo '<option value="'.$name.'">'.$name.'</option>';
}
That spits me out $name as "SX- Light weight" for instance. How would I access the [bronze] number 4?
foreachloop, or just access them directly thru$value['bronze'], etc.valueattribute value. You can ALWAYS safely omit this html markup bloat and rely solely on the text value. No javascript or form submission processes will be affected by writing leaner option markup in this way.