Page 1 of 1

eregi function

Posted: Fri Mar 24, 2006 2:17 pm
by pedroz
$comma[0] can be $comma[0]=',' or $comma[0]='.'

I know this works like this: WORKING

Code: Select all

$form="120.00";
if (!eregi("\.", $form) || !eregi("\,", $form) ) echo "no comma"; else echo "comma";

I would like to use $comma[0] in eregi function but until now without sucess...
NOT WORKING

Code: Select all

$form="120.00";
if (!eregi("\$comma[0]", $form)) echo "no comma"; else echo "comma";

Posted: Fri Mar 24, 2006 2:53 pm
by infolock
what you are asking makes no sense. all i can say is do this :

Code: Select all

if (!eregi("\{$comma[0]}", $form)) echo "no comma"; else echo "comma";

Posted: Fri Mar 24, 2006 4:20 pm
by John Cartwright
fyi, preg_* is often much faster than ereg

Posted: Fri Mar 24, 2006 4:21 pm
by feyd
why even use regex at all for this? , and . are so easy to search for with strpos()