I want to create an multidimensional array this from following code.
var i = 0;
$('.button_image').each(function () {
buttons[i]['left'] = $(this).position().left;
buttons[i]['top'] = $(this).position().top;
i++;
});
Array should be like this
buttons[1]['left']=10;
button[1][top]=20;
buttons[2]['left']=40;
button[2][top]=50;
but it gives following error on firefox console.
TypeError: buttons[i] is undefined
buttons[i]['left']=$(this).position().left;
Please tell me what is wrong on my code. Thanks in advance.
I want this format:
[rows] => Array (
[0] => Array (
[column1] => hello
[column2] => hola
[column3] => bonjour )
[1] => Array (
[column1] => goodbye
[column2] => hasta luego
[column3] => au revoir ) )