The |push filter (since SPIP 2.0) is applied to a tag returning a PHP array/table (seer #ARRAY) and adds a new value to it.
The key is incremented by 1 for each new value. if no key has been defined for the first value, the table is indexed starting from 0 (the first key is 0).
[(#GET{an_array}|foreach)] displays:
- 5=> one_value
- 6=> another_value
- 7=> a_third_value
The first key is 5 because it was specified during the creation of the table (the initial #SET command).
A common usage example of |push:
If the articles selected by the (BOUCLE) LOOP bear the numbers 2, 5 and 10, [(#GET{my_articles}|foreach)] will return:
- 0=>2
- 1=>5
- 2=>10
In this case, the first key is zero since there was no key defined beforehand.
In contrast to the [ PHP function array_push<code>->http://ch.php.net/manual/en/function.array-push.php], the SPIP <code>|push filter does not generate an error message if the filtered tag is not a table.
