note 103781 added to function.is-array

From: Date: Tue, 03 May 2011 16:19:38 +0000
Subject: note 103781 added to function.is-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-179377@lists.php.net to get a copy of this message
Yet another is_assoc function: <?php public static function is_assoc($arr) { if(!is_array($arr)) return false; $i=0; foreach($arr as $k=>$v) { if($k !== $i) return true; ++$i; } return false; } ?> This one checks that all the keys are numbers and are in sequence. This should be more similar how json_encode works when determining how the output should look. If they aren't in sequence, 0,1,2... then obviously they've been modified in some way, and thus are probably significant. ---- Server IP: 66.207.199.35 Probable Submitter: 96.53.64.82 ---- Manual Page -- http://www.php.net/manual/en/function.is-array.php Edit -- https://master.php.net/note/edit/103781 Del: integrated -- https://master.php.net/note/delete/103781/integrated Del: useless -- https://master.php.net/note/delete/103781/useless Del: bad code -- https://master.php.net/note/delete/103781/bad+code Del: spam -- https://master.php.net/note/delete/103781/spam Del: non-english -- https://master.php.net/note/delete/103781/non-english Del: in docs -- https://master.php.net/note/delete/103781/in+docs Del: other reasons-- https://master.php.net/note/delete/103781 Reject -- https://master.php.net/note/reject/103781 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#179377) next »