|
Posted by Koncept on 11/02/06 21:25
In article <Fzs2h.252$AR2.105@newsfe04.lga>, Steve <no.one@example.com>
wrote:
> | <?php
> | $test['k1']['k2'] = 'hello';
> | $test['k1']['k2']['k3'] = 'world';
> |
> | /*
> | Array
> | (
> | [k1] => Array
> | (
> | [k2] => wello
> | )
> |
> | )
> | */
> | ?>
>
> you are forcing to treat the string "hello" as an array...and php is mixing up the
> hash for k2 when retrieving it as a result.
Labelled as "poor programming" or not, I am only interested in
understanding why this is happening based on the code provided.
If I were forcing to treat the string "hello" as an array, wouldn't php
be kind enough to automagically create an index of 0 for this value in
[k1][k2], or at the least, throw up a nice juicy warning telling me
that I'm an idiot for trying to kick it in the nuts?
$test[] = "hello"; // would create an automatic index of 0 for the
value "hello"
What I expected (at the very least) is that k2 would be preserved as
"hello" at index 0, while all other keys and values of the $test hash
would be ignored. How come the first character of k3's value is
maintained, yet at the same time, overwritten with characters one
onwards from string k2?
I still don't follow the process. How *exactly* is PHP mixing up the
process?
--
Koncept <<
"The snake that cannot shed its skin perishes. So do the spirits who are
prevented from changing their opinions; they cease to be a spirit." -Nietzsche
Navigation:
[Reply to this message]
|