📖How to use?

The guide assumes intermediate level knowledge of PHP-language and poggit-virion

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

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

use kim\present\utils\arrays\ArrayUtils;

There are 4 ways to create ArrayUtils.

⚡ 1. Use constructor

In the most basic way, it's just created through the constructor.

$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() in java script

$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() in java script

$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

All methods can be called statically with the suffix From

echo ArrayUtils::joinFrom([1,2,3,4,5], ", "); //1, 2, 3, 4, 5

Last updated