Removing ' from strings

Hey, I'm getting input from a form in html, and then writing that information to a file. Now, when a ' (and i suppose a " as well) is typed in... into the file ' appears. I understand why it is doing this... but is there a way so it DOESN'T do that.. I am sure there's some function that removes it or something but I don't know what it is. I just iddn't want to have to loop through the whole file and remove occurences of ' and things like that. Any help is appreciated.
I'm hoping there's a function that can remove it from the string so i can do:

1)Get text from input box
2)remove the ' and stuff
3)write to file

thanks

Comments

  • sure, you can use the str_replace function. here's an example

    $my_str = "hello. isn\'t it annoying to see \' in my file?!";
    // now my string literally is:
    // "hello. isn't it annoying to see ' in my file"
    //
    // i assume you'd like to turn a ' into just a '
    //
    // you can do this with one call to str_replace

    $my_str = str_replace("\'", "'", $my_str);

    // or if you want to take out the ' altogether, use
    // this line instead

    $my_str = str_replace("\'", "", $my_str);

    hope this helps,
    --------
    awulf :.
    --------
    bus: http://www.inversiondesigns.com
    me : http://awulf.inversiondesigns.com

  • : Hey, I'm getting input from a form in html, and then writing that information to a file. Now, when a ' (and i suppose a " as well) is typed in... into the file ' appears. I understand why it is doing this... but is there a way so it DOESN'T do that.. I am sure there's some function that removes it or something but I don't know what it is. I just iddn't want to have to loop through the whole file and remove occurences of ' and things like that. Any help is appreciated.
    : I'm hoping there's a function that can remove it from the string so i can do:
    :
    : 1)Get text from input box
    : 2)remove the ' and stuff
    : 3)write to file
    :
    : thanks
    :

    couldn't you just use stripslashes ()?

  • : Hey, I'm getting input from a form in html, and then writing that information to a file. Now, when a ' (and i suppose a " as well) is typed in... into the file ' appears. I understand why it is doing this... but is there a way so it DOESN'T do that.. I am sure there's some function that removes it or something but I don't know what it is. I just iddn't want to have to loop through the whole file and remove occurences of ' and things like that. Any help is appreciated.
    : I'm hoping there's a function that can remove it from the string so i can do:
    :
    : 1)Get text from input box
    : 2)remove the ' and stuff
    : 3)write to file
    :
    : thanks
    :


    both of you are correct. Damn thanks a lot

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories