note 110567 added to function.is-array

From: Date: Wed, 07 Nov 2012 20:10:53 +0000
Subject: note 110567 added to function.is-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-191797@lists.php.net to get a copy of this message
Easiest way to check if array is associative <source>function is_assoc (array $input) { for ($i = 0; $i < count ($input); $i++) { if (!isset ($input[$i])) { return TRUE; } } return FALSE; }</source> This is not the fastest solution, but it detects arrays with "holes" and report them as associative... ---- Server IP: 69.147.83.199 Probable Submitter: 178.94.42.162 ---- Manual Page -- http://www.php.net/manual/en/function.is-array.php Edit -- https://master.php.net/note/edit/110567 Del: integrated -- https://master.php.net/note/delete/110567/integrated Del: useless -- https://master.php.net/note/delete/110567/useless Del: bad code -- https://master.php.net/note/delete/110567/bad+code Del: spam -- https://master.php.net/note/delete/110567/spam Del: non-english -- https://master.php.net/note/delete/110567/non-english Del: in docs -- https://master.php.net/note/delete/110567/in+docs Del: other reasons-- https://master.php.net/note/delete/110567 Reject -- https://master.php.net/note/reject/110567 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#191797) next »