note 103781 deleted from function.is-array by danbrown
| From: | danbrown@php.net | Date: | Tue, 03 May 2011 16:20:18 +0000 |
| Subject: | note 103781 deleted from function.is-array by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-179378@lists.php.net to get a copy of this message | ||
Note Submitter: no at thanks dot com
----
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.