how to put many integers in one variable
#1

When I was just creating a script in which i wanted to assign many integers in one variable, I just done like this:
Код:
new variable;
variable = 1,2,3;
But it came into :expression has no effect.

So, How can I put many integers in a variable.
Reply
#2

A variable can have only 1 value.

You can use arrays like

variable[2][3]...
Reply
#3

PHP код:
new variable[5];

//now u can put up to 5 integers into the variable

//you always have to start counting at 0, thats very important cause the index of all arrays starts at 0 and not at 1

variable[0] = 1;
variable[1] = 2;
variable[2] = 3;
variable[3] = 4;
variable[4] = 5;

//You can also create multidimensional arrays like that:

new variable[5][5];

// you can now put up to 5 x 5 variables in there (25)

variable[0][0] = 1;
variable[0][1] = 1;
variable[0][2] = 1;
variable[0][3] = 1;
variable[0][4] = 1;
variable[1][0] = 1;
variable[1][1] = 1;
variable[1][2] = 1;
variable[1][3] = 1;
variable[1][4] = 1;

//and so on .... 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)