How do I remove quotes from a string

0 votes

How to remove all types of quotes (different languages) from $string?

$string = "my text has \"double quotes\" and 'single quotes'";

Any php code for this?
 

Nov 16, 2020 in PHP by kartik
• 37,490 points
503 views

1 answer to this question.

0 votes

Hello @kartik,

Try this:

str_replace('"', "", $string);
str_replace("'", "", $string);

Otherwise, go for some regex, this will work for html quotes for example:

preg_replace("/<!--.*?-->/", "", $string);

Hope it helps!!

answered Nov 16, 2020 by Niroj
• 82,580 points

Related Questions In PHP

0 votes
1 answer

How Do I Get the Query Builder to Output Its Raw SQL Query as a String?

Hello @kartik, Use the toSql() method on a QueryBuilder instance. DB::table('users')->toSql() would return: select * ...READ MORE

answered Jul 21, 2020 in PHP by Niroj
• 82,580 points
202 views
0 votes
1 answer

How do I restore a dump file from mysqldump?

Hello @kartik, It should be as simple as ...READ MORE

answered Aug 18, 2020 in PHP by Niroj
• 82,580 points
85 views
0 votes
1 answer

How can I remove a specific item from an array?

Hello @kartik, Find the index of the array element you ...READ MORE

answered Aug 28, 2020 in PHP by Niroj
• 82,580 points
69 views
0 votes
1 answer

How to remove all special characters from a string?

Hello @kartik, This should do what you're looking ...READ MORE

answered Sep 17, 2020 in PHP by Niroj
• 82,580 points
1,986 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,580 points
5,641 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,580 points
653 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,580 points
497 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,580 points
6,220 views
0 votes
1 answer

How do I get a YouTube video thumbnail from the YouTube API?

Hello @kartik, Each YouTube video has four generated ...READ MORE

answered Jun 16, 2020 in PHP by Niroj
• 82,580 points
926 views
0 votes
1 answer

How do I UPDATE from a SELECT in SQL Server?

Hello @kartik, In SQL Server, use MERGE MERGE INTO YourTable ...READ MORE

answered Jul 21, 2020 in PHP by Niroj
• 82,580 points
126 views