示例#1
0
 /**
  * Starts 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 StartsWith($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::StartsWith($value, $needle, $ignorecase);
         } else {
             $sub = \BTRString::StartsWith($value, $needle, $ignorecase);
         }
         if ($sub) {
             return true;
         }
     }
     return false;
 }
 public function testStartsWithEmptyHaystack()
 {
     $got = \BTRString::StartsWith("", "x");
     $this->assertFalse($got);
 }