削除する必要があり"from products where id = 153183"
ます。ID は変更される可能性があるため、preg_replace を使用して「from」という単語の後のすべてを削除し、str_replace を使用して from を削除する必要があります。私は以下を持っていますが、これは文字列の最後の場合にのみ単語を削除します。追加する必要があるものを誰かが提案できますか?
//doesn't work
$str = "select id, productdescription, category, price, code, manufacturer, categoryid from products where id = 153183";
$new_str = preg_replace('/from$/', '', $str);