I have seen many posts about how to turn an array into a table, but not nearly as many going the other way. I\'m looking to take a table like this:
There's a good tool: $(table).map, but saldly, it always return flatten array, no matter how many nested .map() is inside (you need two: one for rows and one for cells).
So let's use jQuery.map for tables and tr's and object.map() for cells, having 2nd nesting level return an array
function t2a (tabble){
return $.map($(tabble),function(el,i) {
return $.map($(el).find('tr'),function(el,i) {
return [
$(el).find('td').map(function() {
return $(this).text();
}).get()
];
});
});
}