How to check for " " using explode
How do use explode to chec开发者_运维问答k for " ".
Thanks Jean
Short : you dont.
Long :
if(count(explode(' ',$data))>1) echo "GOT A SPACE";
Correct :
if(strpos($data,' ')!==false) echo "GOT A SPACE";
what do you mean? As in, check if there is a space in a string by using explode?
if (count(explode(" ",$string)) > 1) {
// has 1 or more space
}
But this isn't the most efficient way to do it. You should instead use strpos()
精彩评论