'Deleting text between two strings and quote in php using preg_replace [duplicate]

I have this string:

AND wp_posts.post_location = 'location1' AND wp_posts.post_title = 'RANDOMQUERY' AND wp_posts.post_type = 'custom' AND ((wp_posts.post_status = 'publish'))

I want to remove this part which consist random string:

 AND wp_posts.post_title = 'RANDOMQUERY'

Become like this:

AND wp_posts.post_location = 'location1' AND wp_posts.post_type = 'custom' AND ((wp_posts.post_status = 'publish'))

How to do it in php?

php


Solution 1:[1]

Better use mysqli_real_escape_string with out changing the text.

For more details https://www.php.net/manual/en/mysqli.real-escape-string.php

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sivasankaran K