eregi function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pedroz
Forum Commoner
Posts: 99
Joined: Thu Nov 03, 2005 6:21 am

eregi function

Post 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";
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post 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";
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

fyi, preg_* is often much faster than ereg
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

why even use regex at all for this? , and . are so easy to search for with strpos()
Post Reply