Hi everyone,
I have array with elements like this:
113:12,
1125:36,
1125:39,
1123:26
and I need somehow to get result like this(string):
113:12;1125:36,39;1123:26 can somebody please help?
Thanks
| SitePoint Sponsor |
Hi everyone,
I have array with elements like this:
113:12,
1125:36,
1125:39,
1123:26
and I need somehow to get result like this(string):
113:12;1125:36,39;1123:26 can somebody please help?
Thanks


Code javascript:var array = [ '113:12', '1125:36', '1125:39', '1123:26' ]; var string = array.join(';');
Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript
Thanks for reply.. but what I really need is:
Code JavaScript:var array = [ '113:12', '1125:36', '1125:39', '1123:26' ];
to get
Code JavaScript:var array = [ '113:12', '1125:36,39', '1123:26' ];
in first array, if I have more elements like '1125:36','1125:32','1125:46','1125:39' I would need to have '1125:36,32,46,39' I guess I have to use some loop.. or something to get result like that
Thanks


For what purpose do you require it for?
There is a more standards-based approach to the situation as a JSON object:
Code:{ 113 : [12], 1125 : [36, 39], 1123 : [26] };
Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript
Bookmarks