views:

117

answers:

1

Which scheme according to you is a better one in case of matching?

Is it eregi or stripos or any other method?

+5  A: 

That depends if you want to do exact match or regexp match.

Moreover, eregi is deprecated, is not binary safe and does not work well with UTF-8. For regexp matching you should use preg_match with i flag instead.

vartec
which one is prefferable in which situation??
terrific
If you just need to do a simple substring match, then stripos or strpos are probably best.If you need to match on something more complicated, like matching a pattern of characters, then regular expressions could be the better choice.
Chris AtLee
eregi is deprecated? huh?
SilentGhost
@SilentGhost: http://www.php.net/manual/en/intro.regex.php "Note: As of PHP 5.3.0 this extension is deprecated, calling any function provided by this extension will issue an E_DEPRECATED notice"
vartec
@vartec: oh, thanks. 5.3.0 is not released yet though :)
SilentGhost
yeah, but soon. the problem with ereg is that it doesn't work well with UTF8
vartec