You are here: Re: Why does this array result occur? « All PHP « IT news, forums, messages
Re: Why does this array result occur?

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация