You are here: Re: Arrays: $SomeArray{0} vs. $SomeArray[0] « PHP Programming Language « IT news, forums, messages
Re: Arrays: $SomeArray{0} vs. $SomeArray[0]

Posted by Ira Gladnick on 12/01/06 16:53

Norman Peelman wrote:
> You use { } on strings such as:
>
> $someString1 = "0123456789";
> $someString2 = "rock 'n roll";
>
> echo $someString1{5} will output:
> 5

Interesting.

But I was actually doing an assignment using the brace notation:
SomeArray{0} = $somevalue

And, when I did a print_r($SomeArray), it displayed as being an array
with the zero element being the assigned value (if I change the
assignment to SomeArray{99} = $somevalue, then it shows the 99th array
element as holding $somevalue).

So in this situation it seems that braces are equivalent to array
brackets, and are doing something different than string indexing. But
as mentioned, I can't seem to find any documentation indicating this
usage.

This kind of brace usage came up in the context of a certification
practice exam.

 

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

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