note 28647 added to function.eregi

From: Date: Sun, 19 Jan 2003 17:03:17 +0000
Subject: note 28647 added to function.eregi
Groups: php.notes 
Request: Send a blank email to php-notes+get-42387@lists.php.net to get a copy of this message
I notice a lot of queries involving regular expressions and is_float() regarding currency validation. If you have a version of php that uses the std C ctype.h functions then it will ALWAYS work with the following code. function check_price($price) { $data=split('[.]',$price); if ( count($data) != 2 ) return "false"; if ( ctype_digit($data[0]) && ctype_digit($data[1]) && $data[0][0] != '0') return "true"; else return "false"; } Peter Lorimer http:www.textedit.co.uk webmaster@textedit.co.uk -- http://www.php.net/manual/en/function.eregi.php http://master.php.net/manage/user-notes.php?action=edit+28647 http://master.php.net/manage/user-notes.php?action=delete+28647 http://master.php.net/manage/user-notes.php?action=reject+28647

« previous php.notes (#42387) next »