Pass variable as hidden


/ Published in: PHP
Save to your folder(s)

Pass variable as hidden field
recursively handles array.


Copy this code and paste it in your HTML
  1. <?
  2. /* Pass variable as hidden
  3.  
  4. Pass variable as hidden field
  5. recursively handles array
  6. eg usage: */
  7.  
  8. foreach ($_REQUEST as $key => $val)
  9. pass_hidden($key, $val);
  10. function pass_hidden($key, $val) {
  11. if (is_array($val)) {
  12. foreach ($val as $k => $v)
  13. pass_hidden("{$key}[{$k}]", $v);
  14. } else {
  15. ?><input type="hidden" name="<?=$key?>" value="<?=htmlspecialchars($val)?>">
  16. <?
  17. }
  18. }
  19. ?>

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.