基本上,我有一个多维数组,我需要将它构建成一个简单的字符串。
一个很简单的问题,尽管它已经吞噬了我很长一段时间,因为我似乎无法确定它。
这是一个示例,说明我的数组仅包含 3 个问题:
[["question1","answer1","answer2","answer3","answer4"],["question2","answer1","answer2","answer3","answer4"],["question3","answer1","answer2","answer3","answer4"]]
例如,D.rows[0][0]
将是“question1”和D.rows[2][3]
“answer3”,只是为了澄清。
以下是它必须如何保存到字符串中:
question1,answer1,answer2,answer3,answer4
question2,answer1,answer2,answer3,answer4
question3,answer1,answer2,answer3,answer4
每个元素之间必须有一个逗号,并且每个问题必须用换行符分隔。
这是我目前没有工作的:
var fullString;
for (i = 0; i < csvArray.length; ++i)
{
second = secondArray[i];
for (j = 0; j < second.length; ++j)
{
fullString += entry[j] + "'";
}
fullString += "\n";
}
提前致谢!