# How to use?

{% hint style="info" %}
The guide assumes intermediate level knowledge of **PHP-language** and [**poggit-virion**](https://github.com/poggit/support/blob/master/virion.md)
{% endhint %}

The easiest way to try out ArrayUtils is using the poggit. Poggit automatically merges virions, it is better to use this feature.

## :hash:Importing ArrayUtils <a href="#importing" id="importing"></a>

As with all classes, must import ArrayUtils into your php file.

```php
use kim\present\utils\arrays\ArrayUtils;
```

## :hash:Create ArrayUtils from value <a href="#creating" id="creating"></a>

There are 4 ways to create ArrayUtils.

### ⚡ 1. Use constructor

> In the most basic way, it's just created through the constructor.
>
> ```php
> $arr = new ArrayUtils([1,2,3,4,5]);
> echo $arr->join(", "); //1, 2, 3, 4, 5
> ```

### ⚡ 2. Use static from() method

> Same method as [`Array.from()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from) in java script
>
> ```php
> $arr = ArrayUtils::from([1,2,3,4,5]);
> echo $arr->join(", "); //1, 2, 3, 4, 5
> ```

### ⚡ 3. Use static of() method

> Same method as [`Array.of()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of) in java script
>
> ```php
> $arr = ArrayUtils::of(1,2,3,4,5);
> echo $arr->join(", "); //1, 2, 3, 4, 5
> ```

### ⚡ 4. Use magic suffix "From"

> > For a detailed description of the `from-suffix`, [click here](https://arrayutils.docs.present.kim/methods/main#from-suffix)
>
> All methods can be called statically with the suffix `From`
>
> ```php
> echo ArrayUtils::joinFrom([1,2,3,4,5], ", "); //1, 2, 3, 4, 5
> ```

## :hash:Use the desired methods <a href="#using" id="using"></a>

{% content-ref url="/pages/-MKjzUNaOFnOZ6kW1B1-" %}
[📖Methods](/methods.md)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://arrayutils.docs.present.kim/how-to-use.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
