|table_valeur returns the value associated to a given key in a PHP array or table.

|table_valeur{key,default value}

The |table_valeur filter (since SPIP 1.9) applied to a tag that returns a table, accepts a first parameter as a key in the array and returns the value associated with that key. See details about the #ARRAY tag for a more general explanation about array handling in SPIP.


returns green.

The optional default value parameter is used to specify a value to be returned if a value is not found (the key does not exist or the tag filtered does not generate an array).

[(#GET{un_tableau}|table_valeur{3,black})] returns black since there is no key 3.

|table_valeur also works with "linearised" arrays, e.g. the arrays returned by the #ENV and #CONFIG tags (even though these tags have their own syntax to access values in the array).

The above array in linearised form [1] looks like this:


[(#GET{an_array}|table_valeur{2})] always returns green.


Author Mark Published : Updated : 26/10/12

Translations : català, English, Español, français, Nederlands