Searching within an array of strings...

Posted by SoLoGHoST on Stack Overflow See other posts from Stack Overflow or by SoLoGHoST
Published on 2010-05-02T05:22:12Z Indexed on 2010/05/02 5:27 UTC
Read the original article Hit count: 215

Filed under:
|
|

Ok, I'm feeling retarded here,

I have a string like so:

$string = 'function module_testing{';

or it could be like this:

$string = 'function module_testing';

And than I have an array of strings like so:

$string_array = array('module_testing', 'another_function', 'and_another_function');

Now, is there some sort of preg_match that I can do to test if any of the $string_array values are found within the $string string at any given position? So in this situation, there would be a match. Or is there a better way to do this?

I can't use in_array since it's not an exact match, and I'd rather not do a foreach loop on it if I can help it, since it's already in a while loop.

Thanks :)

© Stack Overflow or respective owner

Related posts about php

Related posts about strings