You need to echo
the value of $key
. By now you are just doing <?php $key; ?>
, which does not perform anything. Hence, do:
<?php print $key; ?>"
All together, instead of
<?php
foreach ($json as $key => $value) {
?>
<input type="hidden" name="<?php $key; ?>" value="<?php echo $value; ?>"></input>
^^^^^^^^^^^^^^
<?php
}
Use
<?php
foreach ($json as $key => $value) {
?>
<input type="hidden" name="<?php echo $key; ?>" value="<?php echo $value; ?>"></input>
^^^^^^^^^^^^^^
<?php
}