I found this thread because I'm also looking to trim white-space from email+ password for validation, the number of customers I am getting who say they cannot login is enormous. When I copy/paste their credentials, it works, so the only thing I can come up with, is sloppy copy+paste, ie, they have copied white-space before or after the email and/or password.
So - I was wondering why not use trim()?
The suggestion to use str_replace and the search term " " would only replace a space - what if thy copied a tab character, or a carriage return? Surely trim will clear up all offending characters:
the man page for trim() in php.net says:
http://php.net/manual/en/function.trim.php
" " (ASCII 32 (0x20)), an ordinary space.
"\t" (ASCII 9 (0x09)), a tab.
"\n" (ASCII 10 (0x0A)), a new line (line feed).
"\r" (ASCII 13 (0x0D)), a carriage return.
"\0" (ASCII 0 (0x00)), the NUL-byte.
"\x0B" (ASCII 11 (0x0B)), a vertical tab.
and why would this not be much more desirable than the method suggested by avvici-arvixe? Am I missing something here? (quite possible).
tia