note 31928 added to function.ereg

From: Date: Fri, 09 May 2003 09:42:52 +0000
Subject: note 31928 added to function.ereg
Groups: php.notes 
Request: Send a blank email to php-notes+get-47726@lists.php.net to get a copy of this message
Here some number tests. //Check Percentage %, integer or decimal numbers ereg('^-{0,1}[0-9]*\.{0,1}[0-9]+?%$',$val) returns false if $val="-4"; returns false if $val="4.2"; returns false if $val="4."; returns true if $val="-4%"; returns true if $val="-56.4%"; returns true if $val="-4.%"; returns false if $val="45%%"; returns false if $val="56%.6%"; //Check integer or decimal numbers ereg('^-{0,1}[0-9]*\.{0,1}[0-9]+?$',$val) with: returns true if $val="-4"; returns true if $val="4.2"; returns true if $val="4."; returns true if $val="-4."; returns false if $val="4%"; returns false if $val="-4.%"; returns false if $val="45.4."; returns false if $val="-54.3."; Hope this help anyone.... -- http://www.php.net/manual/en/function.ereg.php http://master.php.net/manage/user-notes.php?action=edit+31928 http://master.php.net/manage/user-notes.php?action=delete+31928 http://master.php.net/manage/user-notes.php?action=reject+31928

« previous php.notes (#47726) next »