note 68791 added to ref.array

From: Date: Thu, 10 Aug 2006 19:51:51 +0000
Subject: note 68791 added to ref.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-115774@lists.php.net to get a copy of this message
Here are two functions for checking if an array contains numeric or string indexes only. Hope someone else will find them useful. <?php //Check for numeric array function isNumeric($ar) { $keys = array_keys($ar); natsort($keys); //String keys will be last return is_int(array_pop($keys)); } //Check for associative array function isAssoc($ar) { $keys = array_keys($ar); natsort($keys); //Numeric keys will be first return is_string(array_shift($keys)); } ?> ---- Server IP: 194.239.128.50 Probable Submitter: 85.82.137.67 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/ref.array.php Edit -- https://master.php.net/note/edit/68791 Del: integrated -- https://master.php.net/note/delete/68791/integrated Del: useless -- https://master.php.net/note/delete/68791/useless Del: bad code -- https://master.php.net/note/delete/68791/bad+code Del: spam -- https://master.php.net/note/delete/68791/spam Del: non-english -- https://master.php.net/note/delete/68791/non-english Del: in docs -- https://master.php.net/note/delete/68791/in+docs Del: other reasons-- https://master.php.net/note/delete/68791 Reject -- https://master.php.net/note/reject/68791 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#115774) next »