note 28647 deleted from function.eregi by cmb

From: Date: Sun, 20 Oct 2019 08:44:53 +0000
Subject: note 28647 deleted from function.eregi by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-212682@lists.php.net to get a copy of this message
Note Submitter: webmaster at textedit dot co dot uk ---- 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

« previous php.notes (#212682) next »