note 83334 added to function.is-array

From: Date: Wed, 21 May 2008 12:26:06 +0000
Subject: note 83334 added to function.is-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-139579@lists.php.net to get a copy of this message
Just to add to what dan at cain dot sh mentioned, is_array() returns false if the argument is an object, even though objects can be treated as arrays: Example: <?php $arr = array(1, 2, 3); print_r($arr); print((is_array($arr) ? "Is Array" : "Not array") . "\n\n"); class MyObj { var $pMyVar = 4; } $arr = new MyObj; print_r($arr); print((is_array($arr) ? "Is Array" : "Not array") . "\n\n"); ?> Output: Array ( [0] => 1 [1] => 2 [2] => 3 ) Is Array myobj Object ( [pMyVar] => 4 ) Not array ---- Server IP: 87.124.64.96 Probable Submitter: 62.56.110.84 ---- Manual Page -- http://www.php.net/manual/en/function.is-array.php Edit -- https://master.php.net/note/edit/83334 Del: integrated -- https://master.php.net/note/delete/83334/integrated Del: useless -- https://master.php.net/note/delete/83334/useless Del: bad code -- https://master.php.net/note/delete/83334/bad+code Del: spam -- https://master.php.net/note/delete/83334/spam Del: non-english -- https://master.php.net/note/delete/83334/non-english Del: in docs -- https://master.php.net/note/delete/83334/in+docs Del: other reasons-- https://master.php.net/note/delete/83334 Reject -- https://master.php.net/note/reject/83334 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#139579) next »