{"name":"insert","operator":null,"title":"insert","type":"command","url":"https://community.bistudio.com/wiki/insert","revid":377154,"updated":"2026-01-01T10:37:44Z","groups":["HashMap","Arrays","Strings"],"status":"ok","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"2.02"}],"since":{"game":"arma3","name":"Arma 3","version":"2.02"},"arma3_since":"2.02","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Inserts multiple values into Array/String/HashMap.\n\nThe String variant also supports forceUnicode. In the event of a HashMap, values, if they already exist, are replaced.","syntaxes":[{"syntax":"array insert [index, valuesToInsert, onlyIfUnique]","since":null,"effect":null,"exec":null,"params":[{"name":"array","type":"Array of Anything","optional":false,"default":null,"description":null,"types":["Array","Anything"],"since":null,"text":"array : Array of Anything"},{"name":"index","type":"Number","optional":false,"default":null,"description":"index at which the values will be inserted, -1 for append, Arma 3 v2.14 -2 for inserting at the second-to-last position, -3 before that, etc.","types":["Number"],"since":null,"text":"index: Number - index at which the values will be inserted, -1 for append, Arma 3 v2.14 -2 for inserting at the second-to-last position, -3 before that, etc."},{"name":"valuesToInsert","type":"Array of Anything","optional":false,"default":null,"description":"values to insert at the specified index","types":["Array","Anything"],"since":null,"text":"valuesToInsert: Array of Anything - values to insert at the specified index"},{"name":"onlyIfUnique","type":"Boolean","optional":true,"default":"false","description":"only insert if the value is unique in the array, like pushBackUnique","types":["Boolean"],"since":null,"text":"onlyIfUnique: Boolean - (Optional, default false) only insert if the value is unique in the array, like pushBackUnique"}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"binary","operator":null,"left":{"text":"array","types":["Array","Anything"]},"right":{"text":"[index, valuesToInsert, onlyIfUnique]","types":["Array"]}},{"syntax":"string insert [index, substring]","since":null,"effect":null,"exec":null,"params":[{"name":"string","type":"String","optional":false,"default":null,"description":null,"types":["String"],"since":null,"text":"string : String"},{"name":"index","type":"Number","optional":false,"default":null,"description":"index at which the values will be inserted, -1 for append","types":["Number"],"since":null,"text":"index: Number - index at which the values will be inserted, -1 for append"},{"name":"substring","type":"String","optional":false,"default":null,"description":"string to insert","types":["String"],"since":null,"text":"substring: String - string to insert"}],"returns":{"type":"String","types":["String"],"description":"the new string","text":"String - the new string"},"form":"binary","operator":null,"left":{"text":"string","types":["String"]},"right":{"text":"[index, substring]","types":["Array"]}},{"syntax":"hashMap insert [[key1, value1], [key2, value2], ...]","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":"keyN","type":"HashMapKey","optional":false,"default":null,"description":null,"types":["HashMapKey"],"since":null,"text":"keyN: HashMapKey"},{"name":"valueN","type":"Anything","optional":false,"default":null,"description":null,"types":["Anything"],"since":null,"text":"valueN: Anything"}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"binary","operator":null,"left":{"text":"hashMap","types":["HashMap"]},"right":{"text":"[[key1, value1], [key2, value2], ...]","types":["Array"]}},{"syntax":"hashMap insert [splitArray, [keysAndValues]]","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":"splitArray","type":"Boolean","optional":false,"default":null,"description":"determines *keysAndValues* format (see *keysAndValues*'s description)","types":["Boolean"],"since":null,"text":"splitArray: Boolean - determines *keysAndValues* format (see *keysAndValues*'s description)"},{"name":"keysAndValues","type":"Array","optional":false,"default":null,"description":"in format depending on *splitArray*'s value:\n- true - `[[key1, key2, ...], [value1, value2, ...]]`\n- false - `[[key1, value1], [key2, value2], ...]` (same as #Syntax 3, see #Example 3 for the correct format)","types":["Array"],"since":null,"text":"keysAndValues: Array - in format depending on *splitArray*'s value:\n- true - `[[key1, key2, ...], [value1, value2, ...]]`\n- false - `[[key1, value1], [key2, value2], ...]` (same as #Syntax 3, see #Example 3 for the correct format)"}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"binary","operator":null,"left":{"text":"hashMap","types":["HashMap"]},"right":{"text":"[splitArray, [keysAndValues]]","types":["Array"]}}],"examples":[{"text":"```sqf\n\"Test\" insert [0, \"Radio\"];        // returns \"RadioTest\"\n\"Test\" insert [2, \"Radio\"];        // returns \"TeRadiost\"\n\"Test\" insert [-1, \"Radio\"];    // returns \"TestRadio\"\n```","code":["\"Test\" insert [0, \"Radio\"];\t\t// returns \"RadioTest\"\n\"Test\" insert [2, \"Radio\"];\t\t// returns \"TeRadiost\"\n\"Test\" insert [-1, \"Radio\"];\t// returns \"TestRadio\""]},{"text":"```sqf\nprivate _array = [\"a\", \"b\", \"c\"];\n_array insert [0, [\"w\"]]; // _array is now [\"w\", \"a\", \"b\", \"c\"]\n\nprivate _array = [\"a\", \"b\", \"c\"];\n_array insert [-1, [\"w\"]]; // _array is now [\"a\", \"b\", \"c\", \"w\"]\n\nprivate _array = [\"a\", \"b\", \"c\"];\n_array insert [-2, [\"w\"]]; // _array is now [\"a\", \"b\", \"w\", \"c\"] // Arma 3 v2.14\n```","code":["private _array = [\"a\", \"b\", \"c\"];\n_array insert [0, [\"w\"]]; // _array is now [\"w\", \"a\", \"b\", \"c\"]\n\nprivate _array = [\"a\", \"b\", \"c\"];\n_array insert [-1, [\"w\"]]; // _array is now [\"a\", \"b\", \"c\", \"w\"]\n\nprivate _array = [\"a\", \"b\", \"c\"];\n_array insert [-2, [\"w\"]]; // _array is now [\"a\", \"b\", \"w\", \"c\"] // Arma 3 v2.14"]},{"text":"```sqf\n// Notice how the size of the right array changes depending on the format of keysAndValues format\nprivate _map = createHashMap;\n_map insert [false, [\"one\", 1]];\n\nprivate _map = createHashMap;\n_map insert [true, [\"one\"], [1]];\n```","code":["// Notice how the size of the right array changes depending on the format of keysAndValues format\nprivate _map = createHashMap;\n_map insert [false, [\"one\", 1]];\n\nprivate _map = createHashMap;\n_map insert [true, [\"one\"], [1]];"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["HashMap","pushBack","pushBackUnique","append","+","merge"],"notes":[],"categories":["Arma 3: New Scripting Commands","Arma 3: Scripting Commands","Command Group: Arrays","Command Group: HashMap","Command Group: Strings","Introduced with Arma 3 version 2.02","Scripting Commands"]}