note 42498 added to function.is-array

From: Date: Tue, 18 May 2004 21:33:04 +0000
Subject: note 42498 added to function.is-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-69798@lists.php.net to get a copy of this message
This is the best way I have found for figuring out if it is an associative array or not. function is_assoc_array($array) { if (!is_array($array)) return; @eval ("list(\$test) = \$array;"); if (isset($test)) { return 0; // Isn't an assoc array } else { return 1; // Is an assoc array } } This should work as long as list always expects a numeric array :) Hint, Hint, Hint developers, if you change this please add us a real function call ;) ---- Manual Page -- http://www.php.net/manual/en/function.is-array.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+42498 Delete -- http://master.php.net/manage/user-notes.php?action=delete+42498&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+42498&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#69798) next »