Re: Fastest way to find out if a string contains a certain character?

[email protected] (Gary)
Newsgroups php.general
Message-ID <[email protected]>
Peter Lind wrote:

> strstr() returns a string, not a bool
> - which would make it slower, though again, not noticeably so (unless,
> like Ashley points out, you're doing a HUGE number of strstr() calls).

Thanks, both of you. Using strpos saved me 200ms. It wasn't really that
I expected to save a lot of time, more that I was interested to know so
that I do the right thing in the future, since the meaning of the code
is not clearer using one way or the other (i.e. I have to write a
comment either way). And yes, I'd already realised using regex was a bad
idea :)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.