FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

* as a wildcard

 


DjMilez
Is it possible to use * as a wildcard for determining if a variable contains a certain word or number? I have attempted to do this but it didn't work, but then again I never do anything right.
Peterssidan
Are you talking about PHP or MySQL? Is it important that it have to be the * or is it just what you believe?

In MySQL you can do like this to get the rows where 'variable' contains the character m.
Code:
SELECT * FROM table WHERE variable LIKE '%m%'
rvec
in php use strstr()
kv
strstr does not have support for wildcards. use preg_match instead. http://php.net/preg_match
rvec
Quote:
if a variable contains a certain word or number?

that can be done with strstr(), if you really need wildcards then yeah you'll have to use preg_match and there (.*) will act like a wildcard.
DjMilez
Ok, thanks for replying.
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.