| @@ 23-32 (lines=10) @@ | ||
| 20 | * @param array $needles |
|
| 21 | * @return bool |
|
| 22 | */ |
|
| 23 | public static function startsWith(string $haystack, array $needles = []) : bool |
|
| 24 | { |
|
| 25 | foreach ($needles as $needle) { |
|
| 26 | if (strpos($haystack, (string) $needle) === 0) { |
|
| 27 | return true; |
|
| 28 | } |
|
| 29 | } |
|
| 30 | ||
| 31 | return false; |
|
| 32 | } |
|
| 33 | ||
| 34 | /** |
|
| 35 | * Determine if a given string ends with a given substring. |
|
| @@ 41-50 (lines=10) @@ | ||
| 38 | * @param array $needles |
|
| 39 | * @return bool |
|
| 40 | */ |
|
| 41 | public static function endsWith(string $haystack, array $needles = []) : bool |
|
| 42 | { |
|
| 43 | foreach ($needles as $needle) { |
|
| 44 | if (strpos(strrev($haystack), (string) $needle) === 0) { |
|
| 45 | return true; |
|
| 46 | } |
|
| 47 | } |
|
| 48 | ||
| 49 | return false; |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||