note 68174 added to function.is-array

From: Date: Mon, 17 Jul 2006 05:20:28 +0000
Subject: note 68174 added to function.is-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-114836@lists.php.net to get a copy of this message
To add to the chaos (or perhaps clarification) of these notes, here's another is_associative_array() function that I made and use.. <?php function is_associative_array( $var ) { return is_array( $var ) && !is_numeric( implode( array_keys( $var ) ) ); } ?> I guess with this logic you could do the following too: <?php function is_sequential_array( $var ) { return is_array( $var ) && is_numeric( implode( array_keys( $var ) ) ); } ?> I never saw a reason to check if it was empty because if it is, the type seems inconsequential. RJ Gilligan ---- Server IP: 64.71.164.2 Probable Submitter: 66.92.33.37 ---- 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/function.is-array.php Edit -- http://master.php.net/note/edit/68174 Del: integrated -- http://master.php.net/note/delete/68174/integrated Del: useless -- http://master.php.net/note/delete/68174/useless Del: bad code -- http://master.php.net/note/delete/68174/bad+code Del: spam -- http://master.php.net/note/delete/68174/spam Del: non-english -- http://master.php.net/note/delete/68174/non-english Del: in docs -- http://master.php.net/note/delete/68174/in+docs Del: other reasons-- http://master.php.net/note/delete/68174 Reject -- http://master.php.net/note/reject/68174 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#114836) next »