note 116835 added to function.is-int

From: Date: Sat, 07 Mar 2015 16:20:05 +0000
Subject: note 116835 added to function.is-int
Groups: php.notes 
Request: Send a blank email to php-notes+get-201885@lists.php.net to get a copy of this message
Sometimes, we need to validate if a DECIMAL returned by a SQL database is an int or not. DECIMAL always return .000 at end of the string. Then i use: <?php function isInteger($input){ { if(strpos($input,".")) $input=preg_replace("/\.$/","",rtrim(strval($input),"0")); return (ctype_digit($input)); } ?> ---- Server IP: 72.52.91.14 Probable Submitter: 82.233.193.172 ---- Manual Page -- http://php.net/manual/en/function.is-int.php Edit -- https://master.php.net/note/edit/116835 Del: integrated -- https://master.php.net/note/delete/116835/integrated Del: useless -- https://master.php.net/note/delete/116835/useless Del: bad code -- https://master.php.net/note/delete/116835/bad+code Del: spam -- https://master.php.net/note/delete/116835/spam Del: non-english -- https://master.php.net/note/delete/116835/non-english Del: in docs -- https://master.php.net/note/delete/116835/in+docs Del: other reasons-- https://master.php.net/note/delete/116835 Reject -- https://master.php.net/note/reject/116835 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#201885) next »