コード例 #1
0
ファイル: String.php プロジェクト: sdekok/civicrm-core
 /**
  * @param string|array $patterns
  * @param array $allStrings
  * @param bool $allowNew
  *   Whether to return new, unrecognized names.
  * @return array
  */
 public static function filterByWildcards($patterns, $allStrings, $allowNew = FALSE)
 {
     $patterns = (array) $patterns;
     $result = array();
     foreach ($patterns as $pattern) {
         if (!\CRM_Utils_String::endsWith($pattern, '*')) {
             if ($allowNew || in_array($pattern, $allStrings)) {
                 $result[] = $pattern;
             }
         } else {
             $prefix = rtrim($pattern, '*');
             foreach ($allStrings as $key) {
                 if (\CRM_Utils_String::startsWith($key, $prefix)) {
                     $result[] = $key;
                 }
             }
         }
     }
     return array_values(array_unique($result));
 }