Helper function to find a form element by reference


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



Copy this code and paste it in your HTML
  1. /**
  2.  * Helper function to find a form element by reference.
  3.  */
  4. function _find_element(&$element, $element_name, &$form_element) {
  5. if (isset($element[$element_name])) {
  6. $form_element = $element[$element_name];
  7. return TRUE;
  8. }
  9. else {
  10. foreach ($element as $key => $value) {
  11. if (is_array($element[$key])) {
  12. $found = _find_element(&$element[$key], $element_name, &$form_element);
  13. if ($found) {
  14. return TRUE;
  15. }
  16. }
  17. }
  18. }
  19. return FALSE;
  20. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.