Posted by Koncept on 11/03/06 02:30
In article <erskk25p72hq13an8aijhclbjktlgnfh1d@4ax.com>, Michael Fesser
<netizen@gmx.de> wrote:
> Quite simple:
>
> $test['k1']['k2'] is a string. Now you can access every single char of a
> string by simply appending an array-like index, for example:
>
> $string = 'Foo';
> print $string[1];
>
> would output 'o'.
>
> In your case you're trying to access the character at position 'k3'.
> Casted to an integer 'k3' becomes '0', so you're simply overwriting the
> first character of $test['k1']['k2'].
>
> Try this instead:
>
> $test['k1']['k2']['k3'+1] = 'world';
>
> Result? 'hwllo'
>
> Micha
Excellent. Makes perfect sense!
Thanks Michael and Steve. You both covered this in a way that I could
follow. Thanks for putting this into perspective for me.
With regards to the particular example of:
$test['k1']['k2']['k3'+1] = 'world';
In the wise words of Borat ... "Is Nice. I like.".
--
"The Steve who cannot help himself from manipulating my signature will
likely perish sooner than later; as will my reputation with the wife if
I don't get around to those dishes in the sink." -- spiritual apple
--
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
[Back to original message]
|