1234567891011121314151617181920212223 |
- <?php
- //include 'kint.phar';
- function search($pattern, $str) {
- if (preg_match_all("/(?:[^\.]*)($pattern)(?:[^\.]*)/i", $str, $matches, PREG_PATTERN_ORDER) !== false) {
- //d($matches);
- foreach ($matches[0] as $index => $value) {
- $pattern_value = $matches[1][$index];
- echo str_replace($pattern_value, "<span style=\"background-color: yellow\">$pattern_value</span>", $value), "<br><br>";
- }
- }
- }
- if (empty($pattern = $_GET['q'])) {
- return;
- }
- $str = file_get_contents('regexp.txt');
- search($pattern, $str);
|