Strip out all single quotes

I am looking for the best way to strip single quotes as it keeps breaking my important.

so

Read More

The image’s emotiveness enables

only comes through as

The image

It breaks at the single quote ‘ .I need a good way to strip out the tags can someone help.

I have looked at stripslashes();

Whats the best way function to stripout , – £

any help please.

MANAGED TO FIX IT>

Thank you for your help people i manage to fix it using the following function.

string utf8_encode ( string $data )

Cant figure out why it was coming out in that format from the database all i can think is it 6 years old website.

😉

Related posts

Leave a Reply

5 comments

  1. Note: This will remove all single quotes!

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

    example:

    $your_string = "The image’s emotiveness enables.";
    echo str_replace("'", "", $your_string);
    

    output

    The images emotiveness enables.

    If you want to keep single quotes in string you should consider using real escape functions (recommended).

  2. It sounds like what you really want is to encode the single quotes, not remove them. On the assumption that you are inserting into the MySQL database, look into mysql_real_escape_string.

  3. The best way to get rid of specific characters is using str_replace.

    To remove all single quotes from a string:

    $noQuotes = str_replace("'", '', $stringWithQuotes);
    
  4. There is several ways, depending on what are you doing.

    You could use addslashes to escape all single / double quotes. You can unescape it with stripslashes later.

    If you are planning on saving those data into MySQL database, you should use mysql_real_escape_string.

    If you want to output data on HTML page, use htmlspecialchars to convert all special characters into HTML entities.

    The next way is to use str_replace to remove all quotes, as few other people in this thread already mentioned.