You are here

function fz152_form_id_matches in FZ152 7

Same name and namespace in other branches
  1. 8 fz152.module \fz152_form_id_matches()

Check is provided form id is match any of patterns.

1 call to fz152_form_id_matches()
fz152_form_alter in ./fz152.module
Implements hook_form_alter().

File

./fz152.module, line 180
Main file for hooks and custom functions.

Code

function fz152_form_id_matches($form_id, $patterns) {

  // Replace new lines by "|" and wildcard by ".*".
  $to_replace = array(
    '/(\\r\\n?|\\n)/',
    // newlines
    '/\\\\\\*/',
  );
  $replacements = array(
    '|',
    '.*',
  );
  $patterns_quoted = preg_quote($patterns, '/');
  $pattern = '/^(' . preg_replace($to_replace, $replacements, $patterns_quoted) . ')$/';
  preg_match($pattern, $form_id, $matches);
  return $matches;
}