Array

MaplePHP Format Array Library

This PHP library, named MaplePHP\DTO\Format\Arr, provides functionality for formatting arrays. Below is a guide to the methods available in this library.

Array Manipulation Methods

unset(keys)

  • Unsets specified keys from the array.

  • Parameters:

    • keys: Keys that you want to unset (e.g., @unset("username", "password", "email", ...)).

arrayKeys()

  • Gets array keys.

shift(?Str &$shiftedValue = null): self

  • Shifts the first element off the array.

  • Parameters:

    • $shiftedValue: Reference to the variable where the shifted value will be stored.

pop(?Str &$poppedValue = null): self

  • Pops the last element off the array.

  • Parameters:

    • $poppedValue: Reference to the variable where the popped value will be stored.

wildcardSearch(string $search): self

  • Extracts all array items with a specified array key prefix.

  • Parameters:

    • $search: Wildcard prefix to search for.

fill(int $index, int $times, string $value = " "): self

  • Fills the array with a value for a specified range.

  • Parameters:

    • $index: The starting index.

    • $times: The number of elements to fill.

    • $value: The value to fill.

count(): int

  • Returns the count/length of the array.

walk(callable $call): self

  • Applies a user-defined function to each element of the array.

  • Parameters:

    • $call: Callable function to apply to each element.

Last updated