I have an array like
a = ["PG,PGR"]
how to convert this to
["PG","PGR"]
Use the .split(',') function. It splits a string into an array of substrings that were separated by ',' character, and return a new array.For more info about split function please visit this link.
var a = ["PG,PGR"]
a= a[0].split(',');
try this : iterate array and use split(",") which will return you new array.
var a = ["PG,PGR"];
var newArray = new Array();
$.each(a , function(i,v){
newArray.push(v.split(","));
});
alert(newArray);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
Find the below fiddle
var array = ["PG,PGR"]
alert(array[0].split(','));
String.prototype.split()