The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Array Inside of an Array?
Okay... lets say I have 2 variables...
$names[50] = 'Jaxel' $players[3] = 50 Shouldn't therefore... $names[$players[3]] = 'Jaxel' ? I am trying to do this, but I am getting an error... Warning: Illegal offset type in [path] How do I do something like this? |
#2
|
||||
|
||||
Not quite... I think you want an associative array, as opposed to a nested array.
Code:
$players = array( "Jaxel" => 50, "Tiger" => 30, ); $players["Jaxel"] = 50 Nested arrays (like your example) are matrices. Grids, like checker boards... [ ][ ][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ][ ][ ] You make the vertical variable, and the horizontal variable... Consider the multiplication tables... Vertical = X Horizontal = Y x=1|[1][2][3][04][05][06][07] x=2|[2][4][6][08][10][12][14] x=3|[3][6][9][12][15][18][21] And you access them like this... $mutliplicationTable[2][3] == 6 So maybe your example would be better like this $names[50][3] = 'Jaxel' But it's pointless to do that if you only have 1 number for each thing. Otherwise you're just wasting a lot of spaces in a row on the table. That's why it might be better (for your example) to use an associative array. Can you dig it? |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|