Posted By

sorehead on 10/09/06


Tagged

as variable Pass hidden


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

vali29


Pass variable as hidden


 / Published in: PHP
 

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

Pass variable as hidden field recursively handles array.

  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. ?>

Report this snippet  

You need to login to post a comment.