public function testMatchTrueDeepArray() { $data = array("test", array("subtest", "needle")); $got = \BTRArray::Match($data, "/[s]+/"); $this->assertTrue($got); }
/** * Applies a regex search on the array values * @param array $haystack the array to search in * @param string $needle the regex * @return boolean */ static function Match($haystack, $needle) { if (empty($haystack) || empty($needle) || !is_string($needle)) { return false; } foreach ($haystack as $value) { if (is_array($value) || is_object($value)) { $sub = \BTRArray::Match($value, $needle); } else { $sub = \BTRString::Match($value, $needle); } if ($sub === true) { return true; } } return false; }