Validate urls with drupal_match_path

Check if a path matches any pattern in a set of patterns.

drupal_match_path($path, $patterns);

Parameters

  • $path - The path to match
  • $patterns - String containing a set of patterns separated by \n, \r or \r\n

Return value

1 if there is a match, 0 if there is not a match.

Example

$pages = 'node/01';
$match = drupal_match_path($_GET['q'], $pages);
if($match) {
  drupal_set_message('Ok');
}
else {
  drupal_set_message('Noooooooooooooooo', 'error');
}

Add new comment