Return to Snippet

Revision: 1454
at October 9, 2006 11:24 by sorehead


Updated Code
<?
/* Pass variable as hidden

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)?>">
    <?
  }
}
?>

Revision: 1453
at October 9, 2006 11:22 by sorehead


Initial Code
<?
/*pass variable as hidden

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)?>">
    <?
  }
}
?>

Initial URL
http://www.bigbold.com/snippets/posts/show/1729

Initial Description
Pass variable as hidden field
recursively handles array.

Initial Title
Pass variable as hidden

Initial Tags


Initial Language
PHP