note 83334 deleted from function.is-array by danbrown

From: Date: Sat, 27 Dec 2008 16:54:12 +0000
Subject: note 83334 deleted from function.is-array by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-148574@lists.php.net to get a copy of this message
Note Submitter: php at REMOVEME KENNEL17 DOTCO.UK ---- 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

« previous php.notes (#148574) next »