I
I
i_want_to_know_everything2015-08-28 11:01:23
JavaScript
i_want_to_know_everything, 2015-08-28 11:01:23

How to add data to a multidimensional associative array?

in one place of the script I add a subarray onner = 1 to the array 88
how to add another subarray there in the script, twwer = 1 as in PHP it gives an error about an unknown index %twwer%
$array[88] = {oner: 1 }

$array[88]['twwer'] = 1 ;

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Ineshin, 2015-08-28
@i_want_to_know_everything

And everything works fine for me:
jsfiddle.net/IonDen/8nnm6txn
Show a little more code.

T
Tema, 2015-08-28
@Tem_ka

var array = [];
array[88] = {oner:1}; // Присвоили элементу массива объект
array[88].oner == 1  // true
array[88].twwer = 1 // Добавили новое свойство объекту array[88]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question