Skip to content Skip to sidebar Skip to footer

Store Comma Separate Values Into Array

I want to store comma separate values into array. Later i want check it with different check. var_str= name,address,state,city // I want make array from this variable How could i

Solution 1:

(Assuming that you have a string and want to convert it to an array)Split method on strings splits strings on a separator.

var str = "name,address,state,city";
var arr = str.split(',');

Solution 2:

if you have such string:

var _str= 'name,address,state,city';

to get array from string use split javascript function:

var arr = _str.split(",");

Solution 3:

If they're strings, jut give it array notation:

var str = [name,address,state,city];

in this array str[0] would be name, etc. If they're not string's variables...I'm unsure what you're asking.

Post a Comment for "Store Comma Separate Values Into Array"