开发者

How to check for " " using explode

开发者 https://www.devze.com 2023-02-16 00:06 出处:网络
How do use explode to chec开发者_运维问答k for \" \". Thanks JeanShort : you dont. Long : if(count(explode(\' \',$data))>1) echo \"GOT A SPACE\";

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

精彩评论

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