Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.
Revision as of 21:51, 18 April 2026 by Shirra (talk | contribs) (Created page with "{{Documentation/Header}} {{High Risk}} {{Lua|Array}} Divides a string into a formatted list of substrings. ==Syntax== * {{F|1}} — arrayString - the input string, each item separated by {{F|2}}. * {{F|2}} — separator - the character or substring to split on. * {{F|3}} — format - the resulting format of each substring. * {{F|4}} — join (optional) - separator between each element to join. Default no separator. ** {{F|{item} }} is replaced with the i...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
This is the documentation page for Array.
It contains usage information, categories, and other content not part of the original template page.
This template is used on 1,473 pages, or on about 53.23% of all pages.
Edits to this template will be widely noticed. To avoid large-scale disruption and unnecessary server load, any changes to this template should be tested in its sandbox or testcases subpages, or in your own user space. The tested changes can then be added to this page in one single edit.
Please consider discussing any changes in the wiki's Discord.
This template uses Module:Array (edit | hist), a script written in Lua.

Divides a string into a formatted list of substrings.

Syntax edit

  • 1 — arrayString - the input string, each item separated by 2.
  • 2 — separator - the character or substring to split on.
  • 3 — format - the resulting format of each substring.
  • 4 — join (optional) - separator between each element to join. Default no separator.
    • {item} is replaced with the item.
    • {newline} is replaced with a newline.
    • {index} is replaced with the index.
  • sort — (optional) set to 1 to sort the items in the array in ascending order, -1 for descending.
  • dedupe — (optional) set to 1 to remove duplicate items from array.
  • noTrim — (optional) set to 1 to not remove whitespace from items in the array.
  • removeEmpty — (optional) set to 1 to remove empty items from array.
  • sentence — (optional) set to 1 to display as sentence.
    • sentence_join — (optional) join character. Default ,
    • sentence_last — (optional) last item join word. Default and
  • prefix — (optional) text added to start of result.
  • suffix — (optional) text added to end of result.
  • template — (optional) set to 1 to allow escaped template syntax for complex returns
    • escape {{ as: ²{ or ^2{.
    • escape }} as: or }^2.
    • escape | as: ¦ or ¹.
  • existLink — (optional) set to 1 to automatically link the resulting string if a page by the same name exists, only for simple lists.

Examples edit

{{Array|1,2,3,4,5|,|*''{item}''{newline} }} yields:

  • 1
  • 2
  • 3
  • 4
  • 5


{{Array|1,2,2,2,3,4,5|,|*''{item}''{newline}|dedupe = 1}} yields:

  • 1
  • 2
  • 3
  • 4
  • 5


{{Array|Dorjelang;Isaki;Rebella;Mobai;Mors|;|*{item}{newline}|sort = 1}} yields:

  • Dorjelang
  • Isaki
  • Mobai
  • Mors
  • Rebella


{{Array|Dorjelang;Rebella;Frostia|;|[[{item}]]|XXX}} yields: DorjelangXXXRebellaXXXFrostia
{{Array
|Frostia;Yunguo;Frostia
|;
|[[{item}]]
|sentence = 1
|prefix = In Coziness Test, 
|suffix =  are available.
}}

yields: In Coziness Test, Frostia, Yunguo, and Frostia are available.
{{Array|a&&b&&c&&d&&e|&&|{index}: {item}|, }} yields: 1: a, 2: b, 3: c, 4: d, 5: e
{{Array|Broken Wood;Flamewood;Tree Sap|;|3 = {{Item|{item}|x = 50}}[[File:{item} Icon.png|30x30px|alt={item}|link={item}]] [[{item}|{item}]] ×50}} yields:
{{Item|{item}|x = 50}}Broken Wood Broken Wood ×50{{Item|{item}|x = 50}}Flamewood Flamewood ×50{{Item|{item}|x = 50}}Tree Sap Tree Sap ×50
{{Array
|Flamewood,Tree Sap,Broken Wood
|,
|3 = ²{#switch:{item}¦Flamewood¦Tree Sap¦=[[:Category:Uses {item}]]¦#default=invalid}²
|$$
|template = 1
}}

yields: Category:Uses Flamewood$$Category:Uses Tree Sap$$invalid

Template Data edit

Divides a string into a formatted list of substrings.

Template parameters

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
arrayString1

The input string, each item separated by "separator"

Stringrequired
separator2

The character or substring to split on.

Stringrequired
format3

The resulting format of each substring. Must include {item}. Include "{newline}" for newline character or "{index}" for index of item.

Example
<li>{index}: {item}</li>
Stringrequired
join4

Separator between each element to join.

Default
Empty string.
Stringoptional
sortsort

Set to 1 to sort the items in the array in ascending order, -1 for descending.

Numberoptional
dedupededupe

Set to 1 to remove duplicate items from array.

Booleanoptional
noTrimnoTrim

Set to 1 to not remove whitespace from items in the array.

Booleanoptional
removeEmptyremoveEmpty

Set to 1 to remove empty items from array.

Booleanoptional
sentencesentence

Set to 1 to display as sentence.

Booleanoptional
sentence_joinsentence_join

Join text for sentence.

Default
,
Stringoptional
sentence_lastsentence_last

Last item join text for sentence.

Default
and
Stringoptional
prefixprefix

Text added to start of result.

Stringoptional
suffixsuffix

Text added to end of result.

Templateoptional
templatetemplate

Set to 1 to allow escaped template syntax for complex returns. "²{" or "^2{" for "{{", "}²" or "}^2" for "}}", "¦" or "¹" for "|"

Stringoptional