Ejemplo n.º 1
0
 /**
  * Finds a needle in a (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 Contains($haystack, $needle, $ignorecase = false)
 {
     if (empty($haystack) || empty($needle) || !is_string($needle)) {
         return false;
     }
     foreach ($haystack as $value) {
         if (is_array($value) || is_object($value)) {
             $sub = \BTRArray::Contains($value, $needle, $ignorecase);
         } else {
             $sub = \BTRString::Contains($value, $needle, $ignorecase);
         }
         if ($sub) {
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 2
0
 public function testContainsSubObject()
 {
     $dummy = new \stdClass();
     $dummy->foo = "dummy";
     $got = \BTRArray::Contains(array("test", $dummy), "mm");
     $this->assertTrue($got);
 }