开发者

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()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜