I know eregi allows you to find a pattern in a string, but is there a function that allows you to find multiple patters in a string. If its finds any of the patters then is true.
For example, here is how the regular eregi function is used:
eregi(needle,haystack)
I want to do this
eregi(needle, needle, needle, needle, haystack)
if it finds any of the needles then its true.
Thanks for your help.
mincklerstraat
9:28 am on Oct 24, 2004 (gmt 0)
Don't know of a function like this, would suggest something along these lines:
$needlearray = array('needle1', 'needle2', 'needle3'); $findflag = 0; foreach($needlearray as $v){ if(eregi($v, $haystack)){ $findflag = 1; break; } // end if } // end foreach if($findflag) echo 'found it!';
... if the number of needles is known and static. If it is dynamic, e.g. when an array of needles is given, your solution is better. May the poster decide what's better in his/her situation.
benj0323
3:54 am on Oct 25, 2004 (gmt 0)
Thanks for your help. I finally got it figured out.