arrayutils
  • Home
  • 📖How to use?
    • ⚡Installation
  • 📖Methods
    • ⚡Static method
      • static from()
      • static of()
      • static mapToArray()
    • ⚡Generic method
      • join()
      • every()
      • some()
      • reduce()
        • reduceRight()
      • sum()
      • pop()
      • shift()
      • includes()
      • keyExists()
      • indexOf()
      • find()
        • findIndex()
      • first()
        • keyFirst()
      • last()
        • keyLast()
      • random()
        • keyRandom()
      • splice()
    • ⚡Chain method
      • chunk()
      • column()
      • combine()
      • concat()
        • concatSoft()
      • countValues()
      • diff()
        • diffAssoc()
        • diffKey()
      • fill()
        • fillKeys()
      • filter()
      • flat()
        • flatMap()
      • flip()
      • forEach()
      • intersect()
        • intersectAssoc()
        • intersectKey()
      • keys()
      • map()
        • mapAssoc()
        • mapKey()
      • pad()
      • push()
      • replace()
      • reverse()
      • slice()
      • sort()
        • sortKey()
      • unique()
      • unshift()
      • values()
  • 📖Suffixes
    • ⚡Suffix - From
    • ⚡Suffix - As
  • links
    • 📌Github repo
    • 📌Packagist project
    • 📌Poggit project
Powered by GitBook
On this page
  • Importing ArrayUtils
  • Create ArrayUtils from value
  • ⚡ 1. Use constructor
  • ⚡ 2. Use static from() method
  • ⚡ 3. Use static of() method
  • ⚡ 4. Use magic suffix "From"
  • Use the desired methods

How to use?

PreviousHomeNext⚡Installation

Last updated 4 years ago

The guide assumes intermediate level knowledge of PHP-language and

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.

use kim\present\utils\arrays\ArrayUtils;

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.

$arr = new ArrayUtils([1,2,3,4,5]);
echo $arr->join(", "); //1, 2, 3, 4, 5

⚡ 2. Use static from() method

Same method as in java script

$arr = ArrayUtils::from([1,2,3,4,5]);
echo $arr->join(", "); //1, 2, 3, 4, 5

⚡ 3. Use static of() method

$arr = ArrayUtils::of(1,2,3,4,5);
echo $arr->join(", "); //1, 2, 3, 4, 5

⚡ 4. Use magic suffix "From"

All methods can be called statically with the suffix From

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

Same method as in java script

For a detailed description of the from-suffix,

Use the desired methods

📖
#️⃣
#️⃣
#️⃣
poggit-virion
Array.from()
Array.of()
click here
📖Methods