Need to check for duplicates before adding to search array
-
Ran into problem where a duplicate image tag is found in content and str_replace will replace the <noscript> content with lazy load image when processing duplicates. Not obvious until a page with hundreds of duplicate image tag grew very large with <noscript> tag content.
Fix by checking for search string before adding to array:
if (!in_array($imgHTML,$search)) { array_push($search, $imgHTML); array_push($replace, $replaceHTML); }
- The topic ‘Need to check for duplicates before adding to search array’ is closed to new replies.