note 93651 added to function.is-array

From: Date: Mon, 21 Sep 2009 14:07:55 +0000
Subject: note 93651 added to function.is-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-160886@lists.php.net to get a copy of this message
After some testing of all those functions you've posted, here's the fastest way to check if an array is associative. Hope this helps anyone who, as myself, was wondering which was the best solution... public static function is_associative2($array){ if (is_array($array)) { $i=0; foreach ($array as $k=>$v) { if ($k !== $i) return true; $i++; } } return false; } ---- Server IP: 195.221.21.36 Probable Submitter: 83.201.128.166 ---- Manual Page -- http://www.php.net/manual/en/function.is-array.php Edit -- https://master.php.net/note/edit/93651 Del: integrated -- https://master.php.net/note/delete/93651/integrated Del: useless -- https://master.php.net/note/delete/93651/useless Del: bad code -- https://master.php.net/note/delete/93651/bad+code Del: spam -- https://master.php.net/note/delete/93651/spam Del: non-english -- https://master.php.net/note/delete/93651/non-english Del: in docs -- https://master.php.net/note/delete/93651/in+docs Del: other reasons-- https://master.php.net/note/delete/93651 Reject -- https://master.php.net/note/reject/93651 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#160886) next »