ArrayUtils
Search…
📖
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.

#⃣
Importing ArrayUtils

As with all classes, must import ArrayUtils into your php file.
1
use kim\present\utils\arrays\ArrayUtils;
Copied!

#⃣
Create ArrayUtils from value

There are 4 ways to create ArrayUtils.

⚡ 1. Use constructor

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

⚡ 2. Use static from() method

Same method as Array.from() in java script
1
$arr = ArrayUtils::from([1,2,3,4,5]);
2
echo $arr->join(", "); //1, 2, 3, 4, 5
Copied!

⚡ 3. Use static of() method

Same method as Array.of() in java script
1
$arr = ArrayUtils::of(1,2,3,4,5);
2
echo $arr->join(", "); //1, 2, 3, 4, 5
Copied!

⚡ 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
1
echo ArrayUtils::joinFrom([1,2,3,4,5], ", "); //1, 2, 3, 4, 5
Copied!

#⃣
Use the desired methods

Last modified 11mo ago