Ejemplo n.º 1
0
 public function testEndsWithSubObject()
 {
     $dummy = new \stdClass();
     $dummy->foo = "dummy";
     $got = \BTRArray::EndsWith(array("test", $dummy), "my");
     $this->assertTrue($got);
 }
Ejemplo n.º 2
0
 /**
  * Ends a value in the array with the given needle?
  * @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 EndsWith($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::EndsWith($value, $needle, $ignorecase);
         } else {
             $sub = \BTRString::EndsWith($value, $needle, $ignorecase);
         }
         if ($sub === true) {
             return true;
         }
     }
     return false;
 }