On Wed, May 30, 2007 5:02 pm, stefano federici wrote: > I trying to find a reason why array functions are not allowed to be > used as normal arrays. To clarify, I'm allowed to write > > $arr = array( "maria", "mario", "luigi", "luisa"); > echo $arr[1]; > > but I'm not allowed to write > > echo array( "maria", "mario", "luigi", "luisa")[1]; > > In PHP documentation I read that "array" is a language construct, not > a function. So this may be the reason. But I also tried with > > echo (explode (" ", "maria mario luigi luisa"))[1]; > > and this doesn't work either (even if "explode" is a function). Not > surprisingly, > > $arr = explode (" ", "maria mario luigi luisa"); > echo $arr[1]; > > does work. So, if I can straightforwardly divide by, say, 2 the > integer output by a function, why shouldn't I be allowed to > straightforwardly use the array output by a function? > > This is not something completely weird that I'm asking. In Visual > Basic (that I know mustn't be the most loved programming language for > PHP users) you can say > > print array( "maria", "mario", "luigi", "luisa")(1) > > Maybe is THIS the reason why it doesn't work in PHP? ;-) > > Thanks for your consideration and help
It was discussed last month, but as I recall, some nasty "what if" scenarios cropped up, and nobody came up with a reasonable way to do this... -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php