I have

$mystring = "Bill's components";

I want to get rid of the ' and replace it with a space (hopefully giving $mystring="Bill s components") so I wrote

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

but this doesn't work; the ' remains in the string.

What to do, please ?

    Is there any possibility the quote you want to replace is not a basic "straight" quote, but a "directional" quote? (Like what MS Word will change it to automatically by default?)

      PS: Your code works fine for me:

      php > $myString = "Bill's Components";
      php > $myString = str_replace("'", " ", $myString);
      php > echo $myString;
      Bill s Components
      php > quit
      
        NogDog;11059469 wrote:

        Is there any possibility the quote you want to replace is not a basic "straight" quote, but a "directional" quote? (Like what MS Word will change it to automatically by default?)

        Some people also call them 'curly quotes.' The basic idea is that it's not the basic single quote mark (or apostrophe) key on your keyboard which is

        '

        which has ASCII code 39.

        Some info here might help spell out the differences a bit.

        How to effectively replace curly quotes sort of depends on your data source's charset encoding. Is it Latin-1? UTF-8?

          Write a Reply...