riouken 15 Posted May 5, 2011 I have a string of an array the string ends up looking like this: ["1","2","3","4"] is there any way to format this and take the [] out? I also need it to be dynamic, I do not know how long the string will be each time. Share this post Link to post Share on other sites
Melmarkian 11 Posted May 6, 2011 (edited) Hi, to get a string out of it I would do: thearray = ["1","2","3","4"]; thestring = format ["%1,%2,%3,%4", thearray select 0, thearray select 1, thearray select 2, thearray select 3]; To do this dynamic.. I don´t know. You can get the number of array elements with count thearray I don´t know about string manipulation in arma/sqf. EDIT: Wasn´t that hard: thearray = ["1","2","3","4","5"]; _string = ""; for "_i" from 0 to (count thearray) -1 do { _string1 = format ["%1,", thearray select _i]; _string = _string + _string1; }; hint _string; EDIT2: And if you want to get rid of the last comma: thearray = ["1","2","3"]; _string = ""; for "_i" from 0 to (count thearray) -1 do { if (_i == ((count thearray) -1)) then { _string1 = format ["%1", thearray select _i]; _string = _string + _string1; }else { _string1 = format ["%1,", thearray select _i]; _string = _string + _string1; }; }; hint _string; Edited May 6, 2011 by Melmarkian Share this post Link to post Share on other sites
riouken 15 Posted May 6, 2011 Thanks for the help man, I just couldn't wrap my head around it before. Thanks again this helps a lot. Share this post Link to post Share on other sites