Arrays demo

From Notaclue Wiki
Extension demonstration (infobox template)
Arrays
Documentation

on mediawiki.org

Maintained by WikiTeq?

No

Version

This wiki has the Arrays extension installed, which adds a few additional parser functions to the MediaWiki parser to deal with arrays.

For example, {{#arraydefine:things|one&two&red&blue&this&that&up&down|&}} defines an array named things with the values [ "one", "two", "red", "blue", "this", "that", "up", "down" ] because the character & was used as the delimiter separating elements.

Given this definition, some example uses are:


Function Description Usage Value for the things array
{{#arrayprint}} Print out an array {{#arrayprint:things}} one, two, red, blue, this, that, up, down
{{#arrayindex}} Access a specific index (indices start at 0) {{#arrayindex:things|3}} blue
{{#arraysize}} Retrieve array size {{#arraysize:things}} 8
{{#arraysearch}} Search for a value (returns index or empty string) {{#arraysearch:things|red}} 2
{{#arraysearch}} Search for a value (substitute values if found or not) {{#arraysearch:things|red|0|yes|no}} yes
{{#arraysearch}} Search for a value (substitute values if found or not) {{#arraysearch:things|purple|0|yes|no}} no
Cookies help us deliver our services. By using our services, you agree to our use of cookies.