Search code examples
phpstr-replacetrim

Removing both single and double quotes from a string


I have being trying to remove both double and single quotes from a string, it is not working. Here is what I mean

text = "Plagiarism is the "wrongful appropriation" and "stealing and publication" of another author's "language";

I would like to trim as this

new text = "Plagiarism is the wrongful appropriation and stealing and publication of another authors language";

I tried this - no way!

$newtext = trim(trim($text,"'"),'"');

I even tried this one too - still no way!

$newtext = str_replace( array( "'","'" ),'',$text);

I simply don't know what I am doing wrong here. Please help. Thanks ):


Solution

  • try the following:

    $text = "Plagiarism is the \"wrongful appropriation\" and \"stealing and publication\" of another author's \"language";
    echo str_replace( array( "'",'"' ),'',$text);