{"name":"in","operator":null,"title":"in","type":"command","url":"https://community.bistudio.com/wiki/in","revid":377765,"updated":"2026-01-03T01:00:35Z","groups":["Strings","Arrays","Locations","HashMap","Unit Control"],"status":"ok","replaced_by":[],"games":[{"game":"ofp","name":"Operation Flashpoint","version":"1.00"},{"game":"ofpe","name":"Operation Flashpoint: Elite","version":"1.00"},{"game":"arma1","name":"Armed Assault","version":"1.00"},{"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":"ofp","name":"Operation Flashpoint","version":"1.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Checks whether value is in array, unit is in vehicle, position is inside location or ANSI string is part of other ANSI string. If Unicode support is desired, see forceUnicode.\n\n> [!NOTE]\n> String comparison is case-sensitive (see Examples **2** and **6**).","syntaxes":[{"syntax":"value in array","since":null,"effect":null,"exec":null,"params":[{"name":"value","type":"Anything","optional":false,"default":null,"description":"any value (cannot  match Array before Arma 3)","types":["Anything"],"since":null,"text":"value: Anything - any value (cannot  match Array before Arma 3)"},{"name":"array","type":"Array","optional":false,"default":null,"description":"array of values","types":["Array"],"since":null,"text":"array: Array - array of values"}],"returns":{"type":"Boolean","types":["Boolean"],"description":null,"text":"Boolean"},"form":"binary","operator":null,"left":{"text":"value","types":["Anything"]},"right":{"text":"array","types":["Array"]}},{"syntax":"unit in vehicle","since":null,"effect":null,"exec":null,"params":[{"name":"unit","type":"Object","optional":false,"default":null,"description":"alive unit","types":["Object"],"since":null,"text":"unit: Object - alive unit"},{"name":"vehicle","type":"Object","optional":false,"default":null,"description":"entity vehicle","types":["Object"],"since":null,"text":"vehicle: Object - entity vehicle"}],"returns":{"type":"Boolean","types":["Boolean"],"description":null,"text":"Boolean"},"form":"binary","operator":null,"left":{"text":"unit","types":["Object"]},"right":{"text":"vehicle","types":["Object"]}},{"syntax":"position in location","since":"arma3 0.50","effect":null,"exec":null,"params":[{"name":"position","type":"Position2D or Position3D","optional":false,"default":null,"description":null,"types":["Position2D","Position3D"],"since":null,"text":"position: Position2D or Position3D"},{"name":"location","type":"Location","optional":false,"default":null,"description":null,"types":["Location"],"since":null,"text":"location: Location"}],"returns":{"type":"Boolean","types":["Boolean"],"description":null,"text":"Boolean"},"form":"binary","operator":null,"left":{"text":"position","types":["Position2D","Position3D"]},"right":{"text":"location","types":["Location"]}},{"syntax":"needle in haystack","since":"arma3 1.96","effect":null,"exec":null,"params":[{"name":"needle","type":"String","optional":false,"default":null,"description":"string to search **for**","types":["String"],"since":null,"text":"needle: String - string to search **for**"},{"name":"haystack","type":"String","optional":false,"default":null,"description":"string to search **in**","types":["String"],"since":null,"text":"haystack: String - string to search **in**"}],"returns":{"type":"Boolean","types":["Boolean"],"description":null,"text":"Boolean"},"form":"binary","operator":null,"left":{"text":"needle","types":["String"]},"right":{"text":"haystack","types":["String"]}},{"syntax":"key in hashMap","since":"arma3 2.02","effect":null,"exec":null,"params":[{"name":"key","type":"HashMapKey","optional":false,"default":null,"description":null,"types":["HashMapKey"],"since":null,"text":"key: HashMapKey"},{"name":"hashMap","type":"HashMap","optional":false,"default":null,"description":null,"types":["HashMap"],"since":null,"text":"hashMap : HashMap"}],"returns":{"type":"Boolean","types":["Boolean"],"description":null,"text":"Boolean"},"form":"binary","operator":null,"left":{"text":"key","types":["HashMapKey"]},"right":{"text":"hashMap","types":["HashMap"]}}],"examples":[{"text":"```sqf\n1 in [0, 1, 2]; // true\n```","code":["1 in [0, 1, 2]; // true"]},{"text":"```sqf\nprivate _myArray = [\"Aaa\", \"AAa\", \"AAA\"];\n\n\"aaa\" in _myArray; // false\n\"AAa\" in _myArray; // true\n\n// Case-insensitive alternatives:\n_myArray findIf { _x == \"aaa\"; } != -1; // true\n\n({\n    if (_x == \"aaa\") exitWith { _forEachIndex };\n    -1\n} forEach _myArray) != -1; // true, less performant but valid before the introduction of the findIf command\n\n{ if (_x == \"aaa\") exitWith { 1 } } count _myArray > 0; // true\n\n{ _x == \"aaa\"; } count _myArray > 0; // true, worst performance, only option available in OFP\n```","code":["private _myArray = [\"Aaa\", \"AAa\", \"AAA\"];\n\n\"aaa\" in _myArray; // false\n\"AAa\" in _myArray; // true\n\n// Case-insensitive alternatives:\n_myArray findIf { _x == \"aaa\"; } != -1; // true\n\n({\n\tif (_x == \"aaa\") exitWith { _forEachIndex };\n\t-1\n} forEach _myArray) != -1; // true, less performant but valid before the introduction of the findIf command\n\n{ if (_x == \"aaa\") exitWith { 1 } } count _myArray > 0; // true\n\n{ _x == \"aaa\"; } count _myArray > 0; // true, worst performance, only option available in OFP"]},{"text":"```sqf\n[1,2,3] in [[1,2,3], [4,5,6]]; // true - Arma 3 only\n```","code":["[1,2,3] in [[1,2,3], [4,5,6]]; // true - Arma 3 only"]},{"text":"```sqf\nprivate _isInCar = player in Car;\n```","code":["private _isInCar = player in Car;"]},{"text":"```sqf\nprivate _isInside = [1000,2000,0] in MyLocation;\n```","code":["private _isInside = [1000,2000,0] in MyLocation;"]},{"text":"```sqf\nprivate _isInString = \"foo\" in \"foobar\"; // true\n_isInString = \"Foo\" in \"foobar\"; // false\n```","code":["private _isInString = \"foo\" in \"foobar\"; // true\n_isInString = \"Foo\" in \"foobar\"; // false"]},{"text":"```sqf\nprivate _onFoot = _unit in _unit;\n```\n\nOther options:\n\n```sqf\nprivate _onFoot = vehicle _unit == _unit;\n```\n\n```sqf\nprivate _onFoot = isNull objectParent _unit;\n```","code":["private _onFoot = _unit in _unit;","private _onFoot = vehicle _unit == _unit;","private _onFoot = isNull objectParent _unit;"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["inPolygon","inArea","find","findIf","toArray","forceUnicode"],"notes":[],"categories":["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: Locations","Command Group: Strings","Command Group: Unit Control","Introduced with Operation Flashpoint version 1.00","Operation Flashpoint: Elite: Scripting Commands","Operation Flashpoint: New Scripting Commands","Operation Flashpoint: Scripting Commands","Scripting Commands","Take On Helicopters: Scripting Commands"]}