有关使用PHP和定界符爆炸的问题

发布于 2025-01-25 14:06:28 字数 459 浏览 1 评论 0原文

如果我使用爆炸件,并且可以用不同的deimiters扫描字符串,则问题是确认定界符是否确实存在,我尝试解释这一点

如果我有:

$ scan =“ test”;

并将其放置:

$ exp =爆炸(“。”,$ scan);

结果总是相同的结果:

print $ exp [0];

给我:

测试

我的问题,我可以如何显示结果 test 如果真的没有定界符,这就是我的测量许多情况我有没有定界符的字符串,但是使用爆炸,并且像我一样,如果不存在在字符串内部不存在,但我认为如果在字符串中使用firt value中的界限,我会看到结果相同[0]。

最好的问候

If i use explode and i can scan string with different deimiters, the problem it´s verificate if delimiter really exists, i try to explain at this point

If i have this :

$scan="test";

And put this :

$exp=explode(".",$scan);

The result always if do this it´s the same :

print $exp[0];

Give me :

test

My question it´s how i can, don´t show the result test if really no have delimiter inside string, this it´s myquestion, because in many cases i have string with no delimiter but use explode and like me don´t show nothing if delimiter don´t exists relly inside string, but i see the result show the same if in the string don´t use delimiter in the firt value [0].

Best Regards

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

口干舌燥 2025-02-01 14:06:28

您可以检查爆炸的结果是否超过1个元素:

$exp=explode(".",$scan);

if (count($exp) > 1) {
// do whatever you want
}

you can check the result of explode if the array count is more than 1 element:

$exp=explode(".",$scan);

if (count($exp) > 1) {
// do whatever you want
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文