note 1826 deleted from count by ronabop

From: Date: Wed, 23 Aug 2000 06:24:35 +0000
Subject: note 1826 deleted from count by ronabop
Groups: php.notes 
Request: Send a blank email to php-notes+get-2945@lists.php.net to get a copy of this message
I'm new to php (version 3.0.12), but seems to me having settype causes the first element added to array to be assigned to the [1] index instead of the [0] index if you're not specifying the index. That might account for some of the count() confusion, unless I'm confused myself. <pre> &lt;?php #try commenting the following line settype($foo, "array"); $foo[] = "amy"; $foo[] = "bobby"; $foo[] = "cathy"; echo 'Count: ' . count($foo) . "<P>n"; echo '$foo[0]: ' . $foo[0] . "<BR>n"; echo '$foo[1]: ' . $foo[1] . "<BR>n"; echo '$foo[2]: ' . $foo[2] . "<BR>n"; echo '$foo[count($foo)]: ' . $foo[count($foo)] . "<P>n"; ?> </pre>

« previous php.notes (#2945) next »