note 1827 deleted from function.settype by didou
| From: | didou@php.net | Date: | Wed, 21 May 2003 16:03:07 +0000 |
| Subject: | note 1827 deleted from function.settype by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-48747@lists.php.net to get a copy of this message | ||
Note Submitter: sidi@angband.org
----
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>
<?php
#try commenting the following line
settype($foo, "array");
$foo[] = "amy";
$foo[] = "bobby";
$foo[] = "cathy";
echo 'Count: ' . count($foo) . "\n";
echo '$foo[0]: ' . $foo[0] . "\n";
echo '$foo[1]: ' . $foo[1] . "\n";
echo '$foo[2]: ' . $foo[2] . "\n";
echo '$foo[count($foo)]: ' . $foo[count($foo)] . "\n";
?>
</pre>