|
@@ 144-146 (lines=3) @@
|
| 141 |
|
$funcIndexOf = $strict ? 'mb_strpos' : 'mb_stripos'; |
| 142 |
|
|
| 143 |
|
// Find the offset of the first needle. |
| 144 |
|
if (false === $firstIndex = $funcIndexOf($haystack, $startNeedle, $offset, $encoding)) { |
| 145 |
|
throw new \OutOfBoundsException('Failed to find $startNeedle ['.$startNeedle.'] in $haystack ['.static::truncate($haystack, 20, '...', false, $encoding).'].'); |
| 146 |
|
} |
| 147 |
|
|
| 148 |
|
// We're going to adjust the offset for the position of the first needle, ie. we're gonna |
| 149 |
|
// start searching for the second one right at the end of the first one. |
|
@@ 153-155 (lines=3) @@
|
| 150 |
|
$offset = $firstIndex + mb_strlen($startNeedle, $encoding); |
| 151 |
|
|
| 152 |
|
// Find the offset of the second needle. |
| 153 |
|
if (false === $secondIndex = $funcIndexOf($haystack, $endNeedle, $offset, $encoding)) { |
| 154 |
|
throw new \OutOfBoundsException('Failed to find $endNeedle ['.$endNeedle.'] in $haystack ['.static::truncate($haystack, 20, '...', false, $encoding).'].'); |
| 155 |
|
} |
| 156 |
|
|
| 157 |
|
// Return the substring between the needles. |
| 158 |
|
return mb_substr($haystack, $offset, $secondIndex - $offset); |
|
@@ 1219-1221 (lines=3) @@
|
| 1216 |
|
$func = $strict ? 'mb_strstr' : 'mb_stristr'; |
| 1217 |
|
$encoding = $encoding ?: static::encoding($haystack); |
| 1218 |
|
|
| 1219 |
|
if (false === $result = $func($haystack, $needle, $before, $encoding)) { |
| 1220 |
|
throw new \RuntimeException('Failed to find $needle ['.$needle.'] in $haystack ['.static::truncate($haystack, 20, '...', false, $encoding).'].'); |
| 1221 |
|
} |
| 1222 |
|
|
| 1223 |
|
return $result; |
| 1224 |
|
} |