tags:

views:

61

answers:

3

I was looking at some code and I came across this line:

 Machine drink[] = {{"Coke", .75,7}, {"Sprite", .55, 2}, { "Pepsi", 1.00, 5}}

At first I thought it was an array, but in php we don't create arrays like this, unless if this is some advanced technique for creating an array that I am not aware of.

And why is it constructed like this?

Coke is a soda.

.75 is the price

And 7 is quantity.

A: 
php > Machine drink[] = {{"DrSalty", .75,7}, {"LemonDew", .55, 2}, { "ChocuRu", 1.00, 5}}

Parse error: syntax error, unexpected T_STRING in php shell code on line 1

This isn't php.

CodeJoust
+5  A: 

Somewhat broken code, but let's pseudo the intentions:

This is an array called drink of object Machine that is being assigned a new element consisting of an array of arrays, where each element contains drink name and then a float (price) and an integer (quantity).

Terry Felkrow
A: 

At first I thought it was javascript object notation (json), but I don't think it's quite right for that either.

(see the json_encode() and json_decode() functions in the php docs)

Mnebuerquo