I am having a problem with my multidimensional array. I am trying to insert an element via AJAX.
I grab the data from inside a table and send it to a PHP file which is meant to print the results but it prints incorrect data.
My HTML table:
<table id="mytable">
<tr>
<td>first</td>
<td>second</td>
<td>third</td>
</tr>
<tr>
<td>fourth</td>
<td>fifth</td>
<td>sixth</td>
</tr>
</table>
Here is my Javascript:
for(i=0; i<=length; i++){
for(j=0;j<width;j++){
//inside of html table grab cell 1x1
data = document.getElementById("mytable").rows[i].cells[j].innerHTML;
//define the Array
export_table[i]= new Array;
export_table[i][j] = data;
}
}
The PHP in my processdata.php:
print_r($_POST)
The problem I see is PHP prints:
Array
(
[0] => ,,first
[1] => ,,,second
)
But I really need it to print:
Array
(
[0] => Array
(
[0] => "first"
[1] => "second"
[2] => "third"
)
[1] => Array
(
[0] => "fourth"
[1] => "fifth"
[2] => "sixth"
)
)