[thelist] PHP - wildcard with stristr()

Bill Haenel bill at webmarketingworx.com
Sat Mar 23 19:33:01 CST 2002


>     | if (
>     |           $file != "."
>     |      and  $file != ".."
>     |      and  stristr("$searchstring", $file)
>     |    )
>
>
> This IF condition sounds ok to me, do you find that this is not working?
> If not, can you give an example of a string from which STRISTR doesn't
> recognize your wildcard pattern?

Say I have files named 'news020303a.ram', 'news020303b.ram', etc. I want
this script to find everything that matches criteria 'news020303*.ram', '*'
being the wildcard.

When I use 'news020303*.ram' as a search criteria ($searchstring in the
above example) I get nothing, assumably because the '*' is interpreted as
part of the string, not as a wildcard(and as it should be, I guess).

Perhaps I need to split $searchstring when the '*' character is found and
look for both pieces of the string that are sitting on either side of the
'*'? Like split $searchstring into $ss_a and $ss_b at the '*' and then do:

if (stristr("$ss_a", $file) and stristr("$ss_b", $file)) {...

???

BH




More information about the thelist mailing list