php check if string contains space code example
Example 1: if name value contains space in php
if ($str == trim($str) && strpos($str, ' ') !== false) {
echo 'has spaces, but not at beginning or end';
}
Example 2: check if string contains only whitespace php
ctype_space(" ") //returns true
ctype_space(" a ") //returns false