chester Posted January 22, 2009 Share Posted January 22, 2009 I'm trying to remove apostrophes from a string. neither of these appear to be working: $ref_fixed = strtr($ref_fixed, "'", ""); $ref_fixed = strtr($ref_fixed, "\'", ""); Suggestions greatly appreciated. Quote Link to comment Share on other sites More sharing options...
bluesoul Posted January 22, 2009 Share Posted January 22, 2009 Try str_replace() instead of strtr(). Same arguments. Quote Link to comment Share on other sites More sharing options...
chester Posted January 22, 2009 Author Share Posted January 22, 2009 Thank you. That does work. Any idea why it would work for one and not the other? Quote Link to comment Share on other sites More sharing options...
bluesoul Posted January 22, 2009 Share Posted January 22, 2009 Yeah, strtr() requires the two strings to be identical lengths, and extra characters are ignored. It's more for this kind of thing: $addr = strtr($addr, "äåö", "aao"); Quote Link to comment Share on other sites More sharing options...
chester Posted January 22, 2009 Author Share Posted January 22, 2009 Which two strings need to be the same length? The string to be tested and the output string? Or the string to be tested for and the string to replace it with? Because this is working for me: $ref_fixed = strtr($ref_fixed, "?", ""); Quote Link to comment Share on other sites More sharing options...
chester Posted January 22, 2009 Author Share Posted January 22, 2009 eh whatever. If it works it works. Marking solved. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.