I am very new to php and I am trying to learn php by myself. I have an array
<?php
$age=array("A"=>"test",
"Arating"=>"37",
"B"=>"test2",
"Brating"=>"40",
"c"=>"test3",
"crating"=>"41",
"D"=>"test4",
"Drating"=>"42");
?>
I would like to create a form from array like Expected output:
<html>
<form action="" name="test" method="post"/>
<input name="A" value="test" id="test"/>
<textarea rows="4" cols="50" name="Arating" >
37
</textarea>
<br>
<input name="B" value="test2" id="test2"/>
<textarea rows="4" cols="50" name="Brating" >
40
</textarea>
<br>
<input name="C" value="test3" id="test3"/>
<textarea rows="4" cols="50" name="Crating" >
41
</textarea>
<br>
<input name="D" value="test4" id="test4"/>
<textarea rows="4" cols="50" name="Drating" >
42
</textarea>
</form>
</html>
<html>
here A B C D will be input type values and textarea should always be Arating,Brating,Crating,Drating
I tried:
<form action="" name="test" method="post"/>
<?php
foreach($age as $key => $value){?>
<input name="<?php echo $key ?>" value="<?php echo $value ?>" id="test"/>
<textarea rows="4" cols="50" name="Arating" >
<?php echo $value ?>
</textarea>
<?php } ?>
Input name always:A,B,C,D
Textarea:Arating,Brating,Crating,Drating
output is totally wrong.I am totally new to php