To use this website fully, you first need to accept the use of cookies. By agreeing to the use of cookies you consent to the use of functional cookies. For more information read this page.

Official ZPE/YASS documentationAssociative arrays

Associative arrays are similar to those found in PHP, as well as having similarities to dictionaries. They differ from ordinary lists in that they store a pair of values. It stores a key which is used to access a value. The key is the left of the fat arrow.

Since these associative arrays are also maps from a key to a value, the associated functions are called map functions, for example map_put. Prior to version 1.9.9, these functions started with associative_array_ instead of map_, for example associative_array_put. Since version 1.9.9 they have been swapped around. Both work in place of each other since prior to version 1.9.9, map_put was an aliase for associative_array_put, however it has since been swapped around.

YASS
$a = [44 => 32, 99 => 93]
  

The empty associative array, which can particularly useful when determining the type of a variable, is represented as [=>]:

YASS
$a = [44 => 32, 99 => 93]
print(get_type($a) == get_type([=>]))
        

Prior to version 1.5.3, associative arrays were enclosed in braces ({ }) as opposed to the square brackets used now ([ ]). This change made only a small difference to coding and has no effect on the underlying representation of associative arrays.

Comments

There are no comments on this page.

New comment
Reply
Code previewClose
Feedback 👍
Comments are sent via email to me.