Official ZPE/YASS documentationMap data type
The map or associative array data type is a very powerful one that features a key to value mapping.
This mapping allows quick access to a value based on its key. The key can be any data type ranging from a string, to a number or an object.
Associative arrays are used in many functions across ZPE/YASS as return values since they offer a fast way of accessing data.
There are several functions that work specifically on associative arrays in ZPE as well as the associative array itself having many built-in reference functions.
Producing an associative array is done with nearly identical syntax to that of the standard list by just using the square brackets syntax [] from version 1.5. Prior to that associative arrays were created using the { } syntax (now reserved for objects). The empty associative array is represented by [>].
$a = ["Jamie" => "Balfour", "Michael" => ["Balfour", "October"]] //The empty map $b = [=>]
Much like the list data type, the map data type can have mixed types for the values, even with strong typing enabled.
Reference functions
The map data type provides several reference functions that allow for ease of use:
- to_string () ⇒ string
- Converts (casts) the map to a string
- get (mixed key) ⇒ mixed
- Gets an item from the map based on its key.
- put (mixed key, mixed value) ⇒ map
- Adds an item to the map.
- remove (mixed key) ⇒ map
- Removes an item based on its key.
There are no comments on this page.