note 119272 added to function.is-numeric

From: Date: Sat, 30 Apr 2016 01:25:58 +0000
Subject: note 119272 added to function.is-numeric
Groups: php.notes 
Request: Send a blank email to php-notes+get-205404@lists.php.net to get a copy of this message
Hey everyone! I have brought a handy function which checks if the input is an IP address. I posted here because it is a numeric string, and uses function is_numeric(); <?php /* is_ipaddress($input) */ function is_ipaddress($input) { $ctra = 0; $tmpout = explode(".",$input); if (count($tmpout) == 4) { // There are four sections in the array (Ex. XXX.XXX.XXX.XXX) // Check if all elements of array are a number (Ex. 127.0.0.1) foreach ($element in $tmpout) { if (is_numeric($element)) { // The element is numeric. ++$ctra; } } // Is the count of numeric elements = 4 ? if ($ctra == 4) { return true; } else { return false; } } else { return false; } } ?> If you can condense this further, please let me know @ my email address I have posted under. Thanks! nJoy~!!! ---- Server IP: 72.52.91.14 Probable Submitter: 45.78.208.51 ---- Manual Page -- http://php.net/manual/en/function.is-numeric.php Edit -- https://master.php.net/note/edit/119272 Del: integrated -- https://master.php.net/note/delete/119272/integrated Del: useless -- https://master.php.net/note/delete/119272/useless Del: bad code -- https://master.php.net/note/delete/119272/bad+code Del: spam -- https://master.php.net/note/delete/119272/spam Del: non-english -- https://master.php.net/note/delete/119272/non-english Del: in docs -- https://master.php.net/note/delete/119272/in+docs Del: other reasons-- https://master.php.net/note/delete/119272 Reject -- https://master.php.net/note/reject/119272 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#205404) next »