Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Wiki Discord
Search
Search
English
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Template:Array/doc
Template
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{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 item. ** {{F|{newline} }} is replaced with a newline. ** {{F|{index} }} is replaced with the index. * {{F|sort}} — (optional) set to 1 to sort the items in the array in ascending order, -1 for descending. * {{F|dedupe}} — (optional) set to 1 to remove duplicate items from array. * {{F|noTrim}} — (optional) set to 1 to not remove whitespace from items in the array. * {{F|removeEmpty}} — (optional) set to 1 to remove empty items from array. * {{F|sentence}} — (optional) set to 1 to display as sentence. ** {{F|sentence_join}} — (optional) join character. Default {{F|,}} ** {{F|sentence_last}} — (optional) last item join word. Default {{F| and }} * {{F|prefix}} — (optional) text added to start of result. * {{F|suffix}} — (optional) text added to end of result. * {{F|template}} — (optional) set to 1 to allow escaped template syntax for complex returns ** escape {{F|<nowiki>{{</nowiki>}} as: {{F|²{}} or {{F|^2{}}. ** escape {{F|<nowiki>}}</nowiki>}} as: {{F|}²}} or {{F|}^2}}. ** escape {{F|<nowiki>|</nowiki>}} as: {{F|¦}} or {{F|¹}}. * {{F|existLink}} — (optional) set to 1 to automatically link the resulting string if a page by the same name exists, only for simple lists. ==Examples== {{T|Array|1,2,3,4,5|,|P3=*''{item}''{newline} }} yields: {{Array|1,2,3,4,5|,|*''{item}''{newline} }}<br> {{T|Array|1,2,2,2,3,4,5|,|*''{item}''{newline}|dedupe=1|_Y_=1}}<br> {{T|Array|Dorjelang;Isaki;Rebella;Mobai;Mors|;|*{item}{newline}|sort=1|_Y_=1}}<br> {{T|Array|Dorjelang;Rebella;Frostia|;|[[{item}]]|XXX|_Y_=1}}<br> {{T|Array|p1=Frostia;Yunguo;Frostia|p2=;|p3=[[{item}]]|p4=sentence=1|p5=prefix=In Coziness Test, |p6=suffix= are available.|_Y_=1|block=1}}<br> {{T|Array|a&&b&&c&&d&&e|&&|{index}: {item}|, |_Y_=1}}<br> {{T|Array|Broken Wood;Flamewood;Tree Sap|;|P3=3={{T|Item|{item}|x=50|NC=1}}|_Ybr_=1}}<br> {{T|Array|Flamewood,Tree Sap,Broken Wood|,|p3=3=²{#switch:{item}¦Flamewood¦Tree Sap¦=[[:Category:Uses {item}]]¦#default=invalid}²|p4=$$|p5=template=1|block=1|_Y_=1}}<br> ==Template Data== <templatedata> { "params": { "1": { "label": "arrayString", "description": "The input string, each item separated by \"separator\"", "type": "string", "required": true }, "2": { "label": "separator", "description": "The character or substring to split on.", "type": "string", "required": true }, "3": { "label": "format", "description": "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>", "type": "string", "required": true }, "4": { "label": "join", "description": "Separator between each element to join.", "type": "string", "default": "Empty string." }, "sort": { "description": "Set to 1 to sort the items in the array in ascending order, -1 for descending.", "type": "number" }, "dedupe": { "description": "Set to 1 to remove duplicate items from array.", "type": "boolean" }, "noTrim": { "description": "Set to 1 to not remove whitespace from items in the array.", "type": "boolean" }, "removeEmpty": { "description": "Set to 1 to remove empty items from array.", "type": "boolean" }, "sentence": { "description": "Set to 1 to display as sentence.", "type": "boolean" }, "sentence_join": { "description": "Join text for sentence.", "type": "string", "default": "," }, "sentence_last": { "description": "Last item join text for sentence.", "type": "string", "default": " and " }, "prefix": { "description": "Text added to start of result.", "type": "string" }, "suffix": { "description": "Text added to end of result.", "type": "wiki-template-name" }, "template": { "description": "Set to 1 to allow escaped template syntax for complex returns. \"²{\" or \"^2{\" for \"{{\", \"}²\" or \"}^2\" for \"}}\", \"¦\" or \"¹\" for \"|\"", "type": "string" } }, "description": "Divides a string into a formatted list of substrings.", "format": "inline" } </templatedata>
Summary:
Please note that all contributions to The Petit Planet Wiki are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
Petit Planet:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Preview page with this template
Below are commonly used wikitext from
MediaWiki:Edittools
. Click on any to insert them in the edit box.
File Pages
==Summary==
==Licensing==
{{Fairuse}}
{{File|}}
Dynamic Page List
¦
²
«
»
²{¦}²
«»
«/»
«!----»
Array in DPL
¹
^2{
}^2
^2{¹}^2
Parser Functions
{{#if:||}}
{{#if:<condition>|<result if true>|<result if false>}}
{{#ifeq:|||}}
{{#ifeq:<text1>|<text2>|<result if text1=text2>|<result if text1≠text2>}}
{{#expr:}}
{{#expr:<mathematical expression>}}
{{#switch:||#default=}}
{{#switch:<text1>|<text2>=<result if text1=text2>|<text3>=<result if text1=text3>|#default=<result if no valid match>}}
{{#replace:||}}
{{#replace:<text1>|<plain text to find in text1>|<plain text to insert in place of the text found>}}
{{#titleparts:}}
{{#replace:<page name>}}
{{#tag:|}}
{{#tag:<name of html tag>|<content inside html tag>}}
Markup
{{}}
|
[]
[[]]
[[Category:]]
#REDIRECT [[]] [[Category:Redirect Pages]]
<code></code>
<includeonly></includeonly>
<noinclude></noinclude>
<nowiki></nowiki>
<!---->
<br>
§
Notices
{{Stub|}}
{{Stub Dialogue}}
{{Upcoming}}
{{Under Construction}}
{{Placeholder|}}
Magic Words
{{!}}
{{formatnum:}}
{{lc:}}
{{uc:}}
{{PAGENAME}}
{{FULLPAGENAME}}
{{ROOTPAGENAME}}
{{BASEPAGENAME}}
{{SUBPAGENAME}}
{{DISPLAYTITLE:|noreplace}}
__TOC__
__NOTOC__
__EXPECTUNUSEDCATEGORY__
__HIDDENCAT__
HTML Entities
—
,
­
Templates used on this page:
Template:Array
(
edit
)
Template:Documentation/Header
(
edit
)
Template:Documentation/styles.css
(
edit
)
Template:Exists
(
edit
)
Template:Extension DPL
(
edit
)
Template:F
(
edit
)
Template:High Risk
(
edit
)
Template:Item
(
edit
)
Template:Lua
(
edit
)
Template:MessageBox
(
edit
)
Template:Namespace
(
edit
)
Template:T
(
edit
)
Module:Arguments
(
edit
)
Module:Arguments/i18n
(
edit
)
Module:Array
(
edit
)
Module:Common/i18n
(
edit
)
Module:Config
(
edit
)
Module:Documentation
(
edit
)
Module:Documentation/config
(
edit
)
Module:Documentation/i18n
(
edit
)
Module:Entrypoint
(
edit
)
Module:Exists
(
edit
)
Module:Fallbacklist
(
edit
)
Module:Feature
(
edit
)
Module:Formatting
(
edit
)
Module:I18n
(
edit
)
Module:Item
(
edit
)
Module:Languages
(
edit
)
Module:Mbox
(
edit
)
Module:Mbox/i18n
(
edit
)
Module:Namespace detect
(
edit
)
Module:Namespace detect/config
(
edit
)
Module:Namespace detect/data
(
edit
)
Module:TableTools
(
edit
)
Module:Yesno
(
edit
)
This page is a member of 2 hidden categories:
Category:Pages using DynamicPageList4
Category:Pages using DynamicPageList4 parser function