| re: eregi or similar_text < -- problem either way
george wrote:[color=blue]
> $page="http://www.google.com/search$search";
> // check to see if on page 1
> $text="my_text_here";
> if (eregi('/\b$text/i', '$page')) {
> echo "Match";
> } else {
> echo "No Match";
> }[/color]
Never matches.
You are checking for
a slash followed by a back slash, b, dollar sign, t, e, x, t, slash, i
in
dollar sign, p, a, g, e
If you want to check for
backslash, b, m, y, underscore, t, e, x, t, underscore, h, e, r, e
in
h, t, t, p, colon, slash, slash, ...
the right eregi() is
eregi('\b' . $text, $page)
The slashes and last "i" you put in the eregi are used for preg_*
functions (which are better than their ereg* counterparts).
[color=blue]
> $page="http://www.google.com/search$search";
> // check to see if on page 1
> $text="my_text_here";
> if (similar_text('/\b$text/i', '$page')) {
> echo "Match";
> } else {
> echo "No Match";
> }[/color]
In my tests I only managed to have similar_text() return 0 (false) with
similar_text('', $something) or similar_text($something, '')
Any two non-empty strings will return at least 1 (true).
The strings you are comparing are here are
slash, backslash, b, dollar sign, t, ...
and
dollar sign, p, a, g, e
To compare
m, y, underscore, t, e, x, t, underscore, ...
and
h, t, p, p, colon, slash, slash, ...
the right similar_text() is
similar_text($text, $page)
NOTE: none of these "corrected" things will check whether
the *contents* of the web page contain whatever is in $text
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =-- |