{"name":"in","title":"in","type":"command","url":"https://community.bistudio.com/wiki/in","revid":379353,"updated":"2026-10-30T23:55:14Z","groups":["Strings","Arrays","Locations","HashMap","Unit Control"],"status":"ok","games":{"ofp":"1.00","ofpe":"1.00","arma1":"1.00","arma2":"1.00","arma2oa":"1.50","tkoh":"1.00","arma3":"0.50"},"since":"ofp 1.00","arma3_since":"0.50","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","params":[{"name":"value","type":"Anything","description":"any value (cannot match Array before Arma 3)","type_expr":"Anything"},{"name":"array","type":"Array","description":"array of values","type_expr":"Array"}],"returns":{"type":"Boolean","type_expr":"Boolean"},"form":"binary","left":{"text":"value"},"right":{"text":"array"}},{"syntax":"unit in vehicle","params":[{"name":"unit","type":"Object","description":"alive unit","type_expr":"Object"},{"name":"vehicle","type":"Object","description":"entity vehicle","type_expr":"Object"}],"returns":{"type":"Boolean","type_expr":"Boolean"},"form":"binary","left":{"text":"unit"},"right":{"text":"vehicle"}},{"syntax":"position in location","since":"arma3 0.50","params":[{"name":"position","type":"Position2D or Position3D","type_expr":"Position2D | Position3D"},{"name":"location","type":"Location","type_expr":"Location"}],"returns":{"type":"Boolean","type_expr":"Boolean"},"form":"binary","left":{"text":"position"},"right":{"text":"location"}},{"syntax":"needle in haystack","since":"arma3 1.96","params":[{"name":"needle","type":"String","description":"string to search **for**","type_expr":"String"},{"name":"haystack","type":"String","description":"string to search **in**","type_expr":"String"}],"returns":{"type":"Boolean","type_expr":"Boolean"},"form":"binary","left":{"text":"needle"},"right":{"text":"haystack"}},{"syntax":"key in hashMap","since":"arma3 2.02","params":[{"name":"key","type":"HashMapKey","type_expr":"HashMapKey"},{"name":"hashMap","type":"HashMap","type_expr":"HashMap","text":"hashMap : HashMap"}],"returns":{"type":"Boolean","type_expr":"Boolean"},"form":"binary","left":{"text":"key"},"right":{"text":"hashMap"}}],"examples":[{"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"]},{"code":["[1,2,3] in [[1,2,3], [4,5,6]]; // true - Arma 3 only"]},{"code":["private _isInCar = player in Car;"]},{"code":["private _isInside = [1000,2000,0] in MyLocation;"]},{"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;"]}],"see_also":["inPolygon","inArea","find","findIf","toArray","forceUnicode"],"notes":[{"user":"Lou Montana","date":"2019-10-08T21:08:00Z","text":"*From a description note:*\n*<unit>* in *<vehicle>* literally does this: `vehicle <unit> == <vehicle>`. If *<vehicle>* is the same as *<unit>* the expression will return true for when the *<unit>* is on foot and false for when *<unit>* is in vehicle (see example **7** & **8**)."}]}