How would I go about detecting whitespace within a string? For example, I have a name string like:
"Jane Doe"
Keep in mind that I don't want to trim or replace it, just detect if whitespace exists between the first and second string.
How would I go about detecting whitespace within a string? For example, I have a name string like:
"Jane Doe"
Keep in mind that I don't want to trim or replace it, just detect if whitespace exists between the first and second string.
You may use something like this:
This will detect a space, but not any other kind of whitespace.
Use preg_match as suggested by Josh:
Ouputs:
Wouldn't preg_match("/\s/",$string) work? The advantage to this over strpos is that it will detect any whitespace, not just spaces.
http://no.php.net/strpos