PHP IF with wildcard

3 posts by 2 authors in: Forums > CMS Builder
Last Post: December 23, 2008   (RSS)

Hi,

Just a quick question, what is the format for wildcards in a PHP IF?

For example I have
$submitted = strtolower($_GET['submitted']);
$answer = 'abc';
<?php if ($answer == ($submitted) ): ?>


So this is defining the variable 'submitted' from the url that is passed.
And defining the variable 'answer' as 'abc'

This works fine.

But I want the IF to work where answer IS LIKE 'submitted'

I have tried all variations using LIKE, % and * but nothing works. For example, this doesn't work...
<?php if ($answer LIKE (%$submitted%) ): ?>

But then I realised that LIKE and % is SQL, not php! And i've tried googling php IF wildcards, but to no avail, which suggests that it's not actually that simple!

Any ideas would be most apprecaited,

Cheers, and merry christmas
Rob

Re: [Dave] PHP IF with wildcard

Hey,

Excellent thanks Dave - I was trying with 'regular expressions' but something with my format must've been wrong as I couldn't get that to work either!

Stripos is perfect for now, so thanks!

Merry Christmas
Rob