如果我在text.txt文件中有以下数据,如何获取这些数据并将其拆分为数组
TXT
arr[0] =>There
arr[1] =>is
arr[2] =>no
arr[3] =>jQuery
arr[4] =>specific
arr[5] =>explode
arr[6] =>method,
arr[7] =>use
arr[8] =>instead
arr[9] =>javascript
arr[10] =>native
答案 0 :(得分:0)
你必须使用eval()。为了拆分文件,你必须稍微改变它的内容。
Txt文件应如下所示(在这种情况下请参阅引号和某种分隔符 - 逗号):
arr[0] => "There",
arr[1] => "is",
arr[2] => "no",
arr[3] => "jQuery",
arr[4] => "specific",
arr[5] => "explode",
arr[6] => "method",
arr[7] => "use",
arr[8] => "instead",
arr[9] => "javascript",
arr[10] => "native",
请参阅working example(查看浏览器控制台的输出)。