How do I replace double quotes with single quotes

后端 未结 8 753
一向
一向 2020-11-30 08:19

How can I replace \"\" (I think it\'s called double quotes) with \'\' (I think its called single quotes) using PHP?

相关标签:
8条回答
  • 2020-11-30 09:14

    For PHP 5.3.7

    $str = str_replace('"',''',$str);
    

    OR

    $str = str_replace('"',"'",$str);
    

    For PHP 5.2

    $str = str_replace('"',"'",$str);
    
    0 讨论(0)
  • 2020-11-30 09:16

    Try with strtr,

    <?php
    $string="hello \" sdfsd dgf";
    echo $string;
    $string = strtr($string, "\"", "'");
    echo $string;
    ?>
    
    0 讨论(0)
提交回复
热议问题