Apr 18, 2002 #1 Greenster Programmer Joined Jan 14, 2002 Messages 30 Location GB In PHP you can turn an array into a string using implode() is there a similar function is javascript? Thanx {Greenster}
In PHP you can turn an array into a string using implode() is there a similar function is javascript? Thanx {Greenster}
Apr 18, 2002 #2 xutopia Programmer Joined Apr 4, 2002 Messages 2,001 Location CA yes and it is called join() var myWords = ["Here", "is", "how", "it", "works."]; var mySentence = myWords.join(" " alert(mySentence) Hope this helps. Gary http://www.xutopia.com Haran Upvote 0 Downvote
yes and it is called join() var myWords = ["Here", "is", "how", "it", "works."]; var mySentence = myWords.join(" " alert(mySentence) Hope this helps. Gary http://www.xutopia.com Haran
Apr 18, 2002 #3 bvallet Programmer Joined Apr 10, 2001 Messages 52 Location US Try: var string = array.join(separator); or var string = array.join(); separator is a variable containing whatever delimiter you want to use, or an empty string is used if it is left out. Upvote 0 Downvote
Try: var string = array.join(separator); or var string = array.join(); separator is a variable containing whatever delimiter you want to use, or an empty string is used if it is left out.
Apr 18, 2002 Thread starter #4 Greenster Programmer Joined Jan 14, 2002 Messages 30 Location GB Thanks very much - that has helped me. Cheers {Greenster} Upvote 0 Downvote
Apr 18, 2002 #5 xutopia Programmer Joined Apr 4, 2002 Messages 2,001 Location CA glad it helped. by the way if you have an array and you alert the array you will get it in a string format seperated by comas. Try : var myWords = ["Here", "is", "how", "it", "works."]; alert(myWords) Gary http://www.xutopia.com Haran Upvote 0 Downvote
glad it helped. by the way if you have an array and you alert the array you will get it in a string format seperated by comas. Try : var myWords = ["Here", "is", "how", "it", "works."]; alert(myWords) Gary http://www.xutopia.com Haran