2012-05-11 48 views
4

我想利用含有一個項目這個陣列(一個STRING與一羣逗號分隔項分割與一個元素的數組成陣列與許多元素

["Bucknell Venture Plan Competition, Mitch Blumenfeld, DreamIt Ventures, Deep Fork Capital, John Ason, Mitchell Blumenfeld, Gianni Martire"]

我想打開它進入這個。包含每個名稱作爲單獨數組項的數組。

["Bucknell Venture Plan Competition", "Mitch Blumenfeld", "DreamIt Ventures", "Deep Fork Capital", "John Ason", "Mitchell Blumenfeld", "Gianni Martire"]

謝謝!

更新:

感謝您的幫助。這工作!

+0

可能重複[如何分割在JavaScript字符串(http://stackoverflow.com/questions/1493407/how-to-split-a-string-in-javascript) –

+0

更好的重複:http://stackoverflow.com/questions/96428/how-do-i-split-this-string-with-javascript –

+2

接受答案,不要更新你的帖子說它的工作。 – epascarello

回答

8

就這麼簡單:

var myArr = ["Bucknell Venture Plan Competition, Mitch Blumenfeld, DreamIt Ventures, Deep Fork Capital, John Ason, Mitchell Blumenfeld, Gianni Martire"]; 
var myNewArr = myArr[0].split(","); 
+1

downvoter是否願意分享投票的理由,還是不合時宜?顯然這是正確的答案。 – Gabe

4

我認爲這應該工作:

var items = ["Bucknell Venture Plan Competition, Mitch Blumenfeld, DreamIt Ventures, Deep Fork Capital, John Ason, Mitchell Blumenfeld, Gianni Martire"]; 
var array = items[0].split(","); 
+0

奇怪的是,同樣的答案,但你得到較少的upvotes作爲先生10k ...幾乎就像他後跟ppl並獲得投票無論 – ppumkin

+1

這可能是「最多投票」收集大多數意見。畢竟,他在我做之前回答:P – Tower

+3

是的,這很奇怪,實際上並非如此。我提前2分鐘回答。 – Gabe