How to remove double quotes from a sql query using with php?

Member

by deron , in category: PHP General , 6 months ago

How to remove double quotes from a sql query using with php?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by dalton_moen , 6 months ago

@deron 

You can remove double quotes from a SQL query using PHP by using the str_replace function. Here's an example:

1
2
3
4
5
6
7
$query = 'SELECT * FROM "users"'; // SQL query with double quotes

// Remove double quotes from the query
$query = str_replace('"', '', $query);

// Use the modified query for further processing
echo $query; // Output: SELECT * FROM users


In the above example, the str_replace function is used to replace all occurrences of double quotes (") with an empty string ('') in the SQL query. This will remove the double quotes from the query.