I have a piece of PHP code which returns an object variable with XML structure as follows:
<food1>
<name1>Belgian Waffles</name1>
<prices1>
<price1>$5.95</price1>
<price2>$8.95</price2>
</prices1>
<description1>Two of our famous Belgian Waffles with plenty of real maple syrup</description1>
<calories1>
<AA>
<A1>650</A1>
<A2>652</A2>
<A3>653</A3>
</AA>
<BB>
<B1>750</B1>
<B2>751</B2>
<B3>752</B3>
</BB>
</calories1>
</food1>
How to write a foreach loop in PHP that produces a variable like $food1
from the above? Then my plan is to insert the $food1
value into a text field in a MySQL database to parse and process the $food1
array whenever is needed.
$food1 = array(
"food1" => array
(
"name1" => Belgian Waffles,
"prices1" => array (
price1 => $5.95
price2 => $8.95
),
"description1" => 'Two of our famous Belgian Waffles with plenty of real maple syrup',
"calories1" => array
(
"AA" => array (
A1 => 650
A2 => 652
A3 => 653
),
"BB" => array (
B1 => 750
B2 => 752
B3 => 753
),
)
);