DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Pass Variable As Hidden

  • submit to reddit
        pass variable as hidden field
recursively handles array
eg usage: 
foreach ($_REQUEST as $key => $val) 
  pass_hidden($key, $val);
function pass_hidden($key, $val) {
  if (is_array($val)) {
    foreach ($val as $k => $v) 
      pass_hidden("{$key}[{$k}]", $v);
  } else {
    ?><input type="hidden" name="<?=$key?>" value="<?=htmlspecialchars($val)?>">