{"name":"toArray","operator":null,"title":"toArray","type":"command","url":"https://community.bistudio.com/wiki/toArray","revid":377121,"updated":"2026-01-01T10:18:13Z","groups":["Arrays","HashMap","Strings"],"status":"ok","replaced_by":[],"games":[{"game":"arma1","name":"Armed Assault","version":"1.09"},{"game":"arma2","name":"Arma 2","version":"1.00"},{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.50"},{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"arma1","name":"Armed Assault","version":"1.09"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Converts the supplied String into an Array of Numbers. The numbers in the created array are the decimal [Unicode](https://en.wikipedia.org/wiki/Unicode) representations of characters.\n\n> [!NOTE]\n> **Arma 3:** Since v2.04 this command can also handle HashMaps. See alternative syntax.","syntaxes":[{"syntax":"toArray string","since":null,"effect":null,"exec":null,"params":[{"name":"string","type":"String","optional":false,"default":null,"description":null,"types":["String"],"since":null,"text":"string: String"}],"returns":{"type":"Array of Numbers","types":["Array","Number"],"description":null,"text":"Array of Numbers"},"form":"unary","operator":null,"left":null,"right":{"text":"string","types":["String"]}},{"syntax":"toArray hashMap","since":"arma3 2.04","effect":null,"exec":null,"params":[{"name":"hashMap","type":"HashMap","optional":false,"default":null,"description":null,"types":["HashMap"],"since":null,"text":"hashMap: HashMap"}],"returns":{"type":"Array","types":["Array"],"description":"array in format [[key, key, ...], [value, value, ...]]","text":"Array - array in format [[key, key, ...], [value, value, ...]]"},"form":"unary","operator":null,"left":null,"right":{"text":"hashMap","types":["HashMap"]}},{"syntax":"hashMap toArray splitArrays","since":"arma3 2.04","effect":null,"exec":null,"params":[{"name":"hashMap","type":"HashMap","optional":false,"default":null,"description":null,"types":["HashMap"],"since":null,"text":"hashMap: HashMap"},{"name":"splitArrays","type":"Boolean","optional":false,"default":null,"description":"see return value","types":["Boolean"],"since":null,"text":"splitArrays: Boolean - see return value"}],"returns":{"type":"Array","types":["Array"],"description":"array in either one of the following formats: - splitArrays: true - `[[key1, key2, ...], [value1, value2, ...]]` - splitArrays: false - `[[key1, value1], [key2, value2], ...]` This is very inefficient since the engine has to create many small arrays","text":"Array - array in either one of the following formats:\n- splitArrays: true - `[[key1, key2, ...], [value1, value2, ...]]`\n- splitArrays: false - `[[key1, value1], [key2, value2], ...]` This is **very inefficient** since the engine has to create many small arrays"},"form":"binary","operator":null,"left":{"text":"hashMap","types":["HashMap"]},"right":{"text":"splitArrays","types":["Boolean"]}}],"examples":[{"text":"```sqf\nhint format [\"%1\", toArray \"AaŒ\"];// Returns \"[65,97,338]\"\n```","code":["hint format [\"%1\", toArray \"AaŒ\"];// Returns \"[65,97,338]\""]},{"text":"```sqf\ntoArray _hashMap params [\"_keys\", \"_values\"];\n```","code":["toArray _hashMap params [\"_keys\", \"_values\"];"]},{"text":"```sqf\nprivate _hashmap = [\"cow\", \"cat\", \"chicken\"] createHashMapFromArray [10000, 20000, 20000];\n_hashmap toArray true;    // returns [[\"cow\", \"cat\", \"chicken\"], [10000, 20000, 20000]] - same as Syntax 2\n_hashmap toArray false;    // returns [[\"cow\", 10000], [\"cat\", 20000], [\"chicken\", 20000]]\n```","code":["private _hashmap = [\"cow\", \"cat\", \"chicken\"] createHashMapFromArray [10000, 20000, 20000];\n_hashmap toArray true;\t// returns [[\"cow\", \"cat\", \"chicken\"], [10000, 20000, 20000]] - same as Syntax 2\n_hashmap toArray false;\t// returns [[\"cow\", 10000], [\"cat\", 20000], [\"chicken\", 20000]]"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["set","resize","reverse","select","in","find","toString","count","deleteAt","splitString","joinString","toUpperANSI"],"notes":[],"categories":["ArmA: Armed Assault: New Scripting Commands","ArmA: Armed Assault: Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: Arrays","Command Group: HashMap","Command Group: Strings","Introduced with Armed Assault version 1.09","Scripting Commands","Take On Helicopters: Scripting Commands"]}