

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.


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.
