3v4l.org

run code in 300+ PHP versions simultaneously
<?phpfunction strposGetContext($haystack, $needle, $context = 10, $ignoreChars = "-\n /") { $ignore = str_split($ignoreChars); $needle = str_replace($ignore, '', $needle); $cleanedHaystack = str_replace($ignore, '', $haystack); $position = 0; $results = []; while (($foundStart = stripos($cleanedHaystack, $needle, $position)) !== false) { $foundEnd = $foundStart + strlen($needle); $position = $foundEnd; $dirtyHaystackPosition = 0; while ($dirtyHaystackPosition < $foundEnd && $dirtyHaystackPosition < strlen($haystack)) { if (in_array($haystack[$dirtyHaystackPosition], $ignore)) { if ($dirtyHaystackPosition <= $foundStart) { $foundStart++; } $foundEnd++; } $dirtyHaystackPosition++; } $results[] = substr( $haystack, $foundStart - $context < 0 ? 0 : $foundStart - $context, $found_end - $found_start + $context ); } return $results;}$text = 'This is some text target-text and we have some string target text you are looking for!!!! target----text WOO';var_dump(strposGetContext($text, 'targettext'));

This is an error 404

There are `0` results


preferences:
127.32 ms | 1399 KiB | 7 Q