groovylobi.blogg.se

Php sorty by key
Php sorty by key









php sorty by key

After using it for a while you won’t want to remember the times before. Map objects are an easy to use and elegant way to handle PHP arrays. Some methods are even better documented than the corresponding PHP array function. values() : Returns all elements with new keysĪgain, the Map documentation offers descriptions, explains parameters/return values and has examples for each method.usort() : Sorts elements using callback.unshift() : Adds an element at the beginning.union() : Combines the element without overwriting.uksort() : Sorts elements by keys using callback.uasort() : Sorts elements with keys using callback.toJson() : Returns the elements in JSON format.splice() : Replaces a slice by new elements.split() : Splits a string into map elements.shuffle() : Randomizes the element order.

php sorty by key

  • shift() : Returns and removes the first element.
  • replace() : Replaces elements recursively.
  • reduce() : Computes a value for the map content.
  • pull() : Returns and removes an element by key.
  • pop() : Returns and removes the last element.
  • merge() : Combines elements overwriting existing ones.
  • map() : Applies a callback to each element and returns the results.
  • krsort() : Reverse sort elements by keys.
  • join() : Returns concatenated elements as string.
  • intersectKeys() : Returns the shared elements by keys.
  • intersectAssoc() : Returns the shared elements and checks keys.
  • intersect() : Returns the shared elements.
  • includes() : Tests if element is included.
  • from() : Creates a new map from passed elements.
  • flat() : Flattens multi-dimensional elements.
  • flip() : Exchanges keys with their values.
  • find() : Returns the first matching element.
  • filter() : Applies a filter to the map elements.
  • equals() : Tests if map contents are equal.
  • each() : Applies a callback to each element.
  • diffKeys() : Returns the missing elements by keys.
  • diffAssoc() : Returns the missing elements and checks keys.
  • count() : Returns the number of elements.
  • collapse() : Collapses multi-dimensional elements.
  • php sorty by key

    arsort() : Reverse sort elements with keys.function map() : Creates a new map from elements.function is_map() : Tests if the variable is a map object.Here’s a list of its methods and for documentation, have a look at the Map readme at GitHub where you can also check the code. The Map object contains methods for almost all array functions available and more like collapse(), flat(), toJson() or methods found in the Javascript Array prototype.











    Php sorty by key