note 79504 added to function.is-int

From: Date: Fri, 30 Nov 2007 17:28:22 +0000
Subject: note 79504 added to function.is-int
Groups: php.notes 
Request: Send a blank email to php-notes+get-132696@lists.php.net to get a copy of this message
a small modification to the isInt checks provided by lclkk at urbanvagabond dot net to make them work for scientific notation integers that are provided in string form: function myIsInt ($x) { return (is_numeric($x) ? intval($x+0) == $x : false); } function Test($x) { echo "$x is " . ( myIsInt($x) ? ('an integer. The integer value is ' . intval($x+0)) : 'not an integer.'); echo "\n"; } Not the additional adding of 0 to $x in both functions. This would allow the following tests to return true: Test('53.45e2'); // 5345 Test('53.45e3'); // 53450 and this one to return false: Test('53.45e1'); // 534.5 ---- Server IP: 64.71.164.2 Probable Submitter: 141.106.144.138 ---- Manual Page -- http://www.php.net/manual/en/function.is-int.php Edit -- https://master.php.net/note/edit/79504 Del: integrated -- https://master.php.net/note/delete/79504/integrated Del: useless -- https://master.php.net/note/delete/79504/useless Del: bad code -- https://master.php.net/note/delete/79504/bad+code Del: spam -- https://master.php.net/note/delete/79504/spam Del: non-english -- https://master.php.net/note/delete/79504/non-english Del: in docs -- https://master.php.net/note/delete/79504/in+docs Del: other reasons-- https://master.php.net/note/delete/79504 Reject -- https://master.php.net/note/reject/79504 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#132696) next »