/** * Finds a needle in an (nested) array. * @param array $haystack The haystack to search in * @param string $needle the needle to find * @param bool $ignorecase should the function work case insensitive? * @return boolean */ static function ContainsIterative($haystack, $needle, $ignorecase = false) { if (empty($haystack) || empty($needle) || !is_string($needle)) { return false; } //saves all arrays $arrayPositions = [$haystack]; for ($i = 0; $i < count($arrayPositions); $i++) { $currentArray = $arrayPositions[$i]; foreach ($currentArray as $value) { if (is_array($value)) { $arrayPositions[] = $value; } else { if (\BTRString::Contains($value, $needle, $ignorecase)) { return true; } } } } return false; }
public function testContainsNeedleInt() { $got = \BTRString::Contains("hallo5", 5); $this->assertTrue($got); }