> For the complete documentation index, see [llms.txt](https://minwork.gitbook.io/array/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://minwork.gitbook.io/array/utility-methods/forcearray.md). # forceArray #### Definition ```php Arr::forceArray(mixed $var, int $flag = self::FORCE_ARRAY_ALL): mixed ``` #### Description Make variable an array (according to flag settings) #### Examples ```php Arr::forceArray(0) -> [0] Arr::forceArray('test') -> ['test'] Arr::forceArray(null) -> [null] Arr::forceArray(null, Arr::FORCE_ARRAY_PRESERVE_NULL) -> null $object = new stdClass(); Arr::forceArray($object) -> [$object] // With this flag all objects remain intact Arr::forceArray($object, Arr::FORCE_ARRAY_PRESERVE_OBJECTS) -> $object $object = new ArrayObject(); Arr::forceArray($object) -> [$object] // With this flag objects implementing ArrayAccess remain intact Arr::forceArray($object, Arr::FORCE_ARRAY_PRESERVE_ARRAY_OBJECTS) -> $object ```