<?php function sanitize($html) { return htmlspecialchars($html); } function sanitize_and_highlight_search_result($data, $query){ $sanitized = sanitize($data); $query = sanitize($query); return str_replace( $query, '<span class="highlight">' . $query . '</span>', $sanitized ); } echo sanitize_and_highlight_search_result("You & me", "&am"); // Shouldn't be found echo "\n"; echo sanitize_and_highlight_search_result("You & me", "&"); // Should be found and highlighted
You have javascript disabled. You will not be able to edit any code.
Value for `_results` contains invalid data `array`