revDAVE wrote:
Newbie - is there a function similar to the sql 'like' comparison operator?
I would like to be able to compare 2 strings:
If $this ---*like or similar to*--- $that
That type of thing...
I know of this page:
http://us3.php.net/manual/sl/language.operators.comparison.php
But I don't see something 'like' or 'similar' to something else
--
Thanks - RevDave
Cool @ hosting4days . com
[db-lists]
Probably the most similar that allows some wildcards (pattern matching)
is ereg(). You have more power in that you can control what must match
and how much.
In MySQL 'a' = ' a ' is true but 'a' LIKE ' a ' is false. So you need
to use the wildcard % to match anything ' xxaxx ' LIKE '%a%' is true or
_ to match one character ' a ' LIKE '_a_' is true.
The problem with similar_text() is that it gives you a percentage of
similarity which may be misleading unless you also figure in the return
of how many chars match. For example similar_text('CAT', 'CA', &$p) $p
would be 66.6%, is that like or not?
-Shawn
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php