This is the old documentation center for eZ Publish 4. We are currently migrating the eZ Publish documentation to http://confluence.ez.no the eZ Publish 5 documentation platform. Documentation for the eZ Publish legacy components are still located on this site, as well as all documentation for earlier releases.

hash

Summary

Creates and returns a new associative array (a hash).

Usage

hash( key1, value1 [, key2, value2 [, ... ] ] )

Parameters

NameTypeDescriptionRequired
key1 string The key of value1. Yes.
value1 any The value associated with key1. Yes.
key2 string The key of value2. No.
value2 any The value associated with key2. No.

Returns

An associative array (a hash).

Description

This operator builds an associative array using the specified key/value pairs. Odd parameters are considered to be keys, even parameters will be values. The operator returns the generated hash.

Examples

Example 1

{hash( 1, 'Red Eyes', 2, 'Green Gremlins', 3, 'Blue Thunder' )}

The following hash will be returned:

Key

Value

1

Red Eyes

2

Green Gremlins

3

Blue Thunder

Balazs Halasy (05/02/2004 10:32 am)

Balazs Halasy (22/11/2005 11:36 am)


Comments

  • On page110 of the ezpublish Basics Book

    The example on p110 can't work. Eighter you can access the data of an associative hash by the index or by the identifier. The given example tells you, you can access a value with an identifier by using the index.

    Feel free to tell me, if i'm wrong.
    • Re: On page110 of the ezpublish Basics Book

      Might be a bug, it was reported here long ago: http://issues.ez.no/10272