I have this function to remove a specific word from a String, this function use a word list.
so i have a query and i want to remove every type of string like (number,number)
this is mycode:
$wordlist = array("LIMIT", "0, 5");
foreach ($wordlist as &$word) {
$word = '/\b' . preg_quote($word, '/') . '\b/';
}
$sql = preg_replace($wordlist, '', $sql);
var_dump($sql);
as you can see, if the function get LIMIT or 0,5 it will be removed, how i can remove any type of word like “number, number” so the query will be LIMIT 10, 40 it will be removed too.
to know if a string is with format of “is_number,is_number”.
thanks.
Use preg_replace() to remove in regular expression marked string