strpos - 和多针? [英] strpos - and multiple needles?

查看:114
本文介绍了strpos - 和多针?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!


我正在阅读php.net,以便在

字符串中找到一些字符。说我想找ab和c ind $ string。

据我所知,没有这个功能。


所以,我可以吗?

1)运行字符串并使用in_array进行测试('''',''b'',''c'')

2)运行数组并使用strpos测试($ items [$ i] ....

我发现#2最好。


但是有没有能更快或更好地做到这一点的功能?

Hi!

I was reading php.net for a way to find a number of characters in a
strings. Say I want to look for a b and c ind $string.
As far as I could see, there is no function for that.

So, I can either?
1) run through the string and test using in_array(''a'', ''b'', ''c'')
2) run through array and test using strpos( $items[$i]....
Where I find #2 the best.

But is there a function which can do that faster or in a better way?

推荐答案

string。

据我所知,没有这个功能。


所以,我可以吗?

1)运行字符串并使用in_array('''''进行测试, ''b'',''c'')

2)运行数组并使用strpos进行测试(
string.
As far as I could see, there is no function for that.

So, I can either?
1) run through the string and test using in_array(''a'', ''b'', ''c'')
2) run through array and test using strpos(


items


i] ....

我觉得#2最好。


但是有没有一个功能可以更快地或在一个更好的方法?
i]....
Where I find #2 the best.

But is there a function which can do that faster or in a better way?


这篇关于strpos - 和多针?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆