note 50496 added to function.eregi

From: Date: Wed, 02 Mar 2005 00:32:33 +0000
Subject: note 50496 added to function.eregi
Groups: php.notes 
Request: Send a blank email to php-notes+get-85758@lists.php.net to get a copy of this message
Sometimes we require checking the syntax of floating point numbers. Here is a php-code that performs this task. // To call this program: // php floats.php //-------------------------- // Example of the use of regular expressions for checking // the syntax of floating point numbers. <?php // This opens standard in ready for interactive input.. $STDIN = fopen("php://stdin","r"); for(;;) { // FOREVER-LOOP echo "Float>"; $s = trim(fgets($STDIN,256)); if ($s) { $le = eregi( "-?(([0-9]+e-?[0-9]+)|((([0-9]+\.[0-9]*)|(\.[0-9]+))" . "(e-?[0-9]+)?))", $s, $regs); if ($le==strlen($s)) echo "Yes it's float\n"; else if ($le > 0) echo "$le chars of the string correspond to a float\n"; else echo "No, it isn't float\n"; } else break; } fclose($STDIN); ?> ---- Manual Page -- http://www.php.net/manual/en/function.eregi.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+50496 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50496&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50496&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50496&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50496&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50496&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+50496&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#85758) next »