I have a form values submitted to update.php file. In update.php file I use:-
foreach ($_POST as $key => $value)
echo $key.'='.$value.'<br />';
This is the echo values I get :-
jan=1
feb=2
mar=3
apr=4
may=5
jun=6
jul=7
aug=8
sep=9
oct=10
nov=11
dec=12
submit1=Submit
I am using following code to write value to sub-child element in xml file
$xml=simplexml_load_file("2020/data.xml");
if(isset($_POST['submit1']))
{
$xml->sales->jan = $_POST['jan'];
file_put_contents("2020/data.xml", $xml->asXML());
}
$xml=simplexml_load_file("2020/data.xml");
if(isset($_POST['submit1']))
{
$xml->sales->feb = $_POST['feb'];
file_put_contents("2020/data.xml", $xml->asXML());
}
............ etc up to $xml->sales->dec = $_POST['dec'];
How can I simplify this repetitive code