PHP Snippets

  • groupBy

    PHP, Array

    Groups the elements of an array based on the given function.

  • orderBy

    PHP, Array

    Sorts a collection of arrays or objects by key.

  • gcd

    PHP, Math

    Calculates the greatest common divisor between two or more numbers.

  • curry

    PHP, Function

    Curries a function to take arguments in multiple calls.

  • pluck

    PHP, Array

    Retrieves all of the values for a given key.

  • deepFlatten

    PHP, Array

    Deep flattens an array.

  • findLastIndex

    PHP, Array

    Returns the index of the last element for which the provided function returns a truthy value.

  • flatten

    PHP, Array

    Flattens an array up to the one level depth.

  • maxN

    PHP, Math

    Returns the maximum value from the provided array.

  • minN

    PHP, Math

    Returns the minimum value from the provided array.

  • reject

    PHP, Array

    Filters the collection using the given callback.

  • rotate

    PHP, Array

    Rotates the array (in left direction) by the number of shifts.

  • compose

    PHP, Function

    Return a new function that composes multiple functions into a single callable.

  • findLast

    PHP, Array

    Returns the last element for which the provided function returns a truthy value.

  • remove

    PHP, Array

    Removes elements from an array for which the given function returns false.

2...4