To make implode in javascript like php use join method.The join() method converts all the elements to strings and then concatenates all the strings into a longer string.
If an argument is provided in the parameter list, it is used to separate the elements in the string returned by the method.
Ex:
<html>
<script language="JavaScript">
fruit = new Array("1","2","3");
String = fruit.join("-");
document.write("The fruit array contains: ",String);
</script>
</html>
Output : 1-2-3
No comments:
Post a Comment