Deprecated: Return type of MediaWiki\Session\PHPSessionHandler::open($save_path, $session_name) should either be compatible with SessionHandlerInterface::open(string $path, string $name): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/web/public_html/wiki/includes/session/PHPSessionHandler.php on line 172

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/web/public_html/wiki/includes/json/FormatJson.php on line 297

Deprecated: Return type of ResultWrapper::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/web/public_html/wiki/includes/db/DatabaseUtility.php on line 174

Deprecated: Return type of ResultWrapper::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/web/public_html/wiki/includes/db/DatabaseUtility.php on line 192

Deprecated: Return type of ResultWrapper::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/web/public_html/wiki/includes/db/DatabaseUtility.php on line 185

Deprecated: Return type of ResultWrapper::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/web/public_html/wiki/includes/db/DatabaseUtility.php on line 202

Deprecated: Return type of ResultWrapper::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/web/public_html/wiki/includes/db/DatabaseUtility.php on line 163

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /home/web/public_html/wiki/includes/db/Database.php on line 1742

Deprecated: Return type of MediaWiki\Session\Session::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/web/public_html/wiki/includes/session/Session.php on line 555

Deprecated: Return type of MediaWiki\Session\Session::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/web/public_html/wiki/includes/session/Session.php on line 560

Deprecated: Return type of MediaWiki\Session\Session::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/web/public_html/wiki/includes/session/Session.php on line 570

Deprecated: Return type of MediaWiki\Session\Session::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/web/public_html/wiki/includes/session/Session.php on line 565

Deprecated: Return type of MediaWiki\Session\Session::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/web/public_html/wiki/includes/session/Session.php on line 580

Deprecated: Return type of MediaWiki\Session\Session::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/web/public_html/wiki/includes/session/Session.php on line 575

Deprecated: Return type of MediaWiki\Session\Session::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/web/public_html/wiki/includes/session/Session.php on line 589

Deprecated: Return type of & MediaWiki\Session\Session::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/web/public_html/wiki/includes/session/Session.php on line 601

Deprecated: Return type of MediaWiki\Session\Session::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/web/public_html/wiki/includes/session/Session.php on line 610

Deprecated: Return type of MediaWiki\Session\Session::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/web/public_html/wiki/includes/session/Session.php on line 614

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /home/web/public_html/wiki/includes/db/Database.php on line 1742

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /home/web/public_html/wiki/includes/db/Database.php on line 1742

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /home/web/public_html/wiki/includes/db/Database.php on line 1742

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /home/web/public_html/wiki/includes/db/Database.php on line 1742

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /home/web/public_html/wiki/includes/db/Database.php on line 1742

Deprecated: Message implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in /home/web/public_html/wiki/includes/Message.php on line 159

Deprecated: RawMessage implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in /home/web/public_html/wiki/includes/Message.php on line 1232

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /home/web/public_html/wiki/includes/db/Database.php on line 1742

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /home/web/public_html/wiki/includes/db/Database.php on line 1742

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /home/web/public_html/wiki/includes/db/Database.php on line 1742

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /home/web/public_html/wiki/includes/db/Database.php on line 1742

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /home/web/public_html/wiki/includes/db/Database.php on line 1742

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /home/web/public_html/wiki/includes/db/Database.php on line 1742

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /home/web/public_html/wiki/includes/db/Database.php on line 1742

Warning: Cannot modify header information - headers already sent by (output started at /home/web/public_html/wiki/includes/session/Session.php:48) in /home/web/public_html/wiki/includes/Feed.php on line 234

Deprecated: header(): Passing null to parameter #3 ($response_code) of type int is deprecated in /home/web/public_html/wiki/includes/WebResponse.php on line 42

Warning: Cannot modify header information - headers already sent by (output started at /home/web/public_html/wiki/includes/session/Session.php:48) in /home/web/public_html/wiki/includes/WebResponse.php on line 42

Deprecated: header(): Passing null to parameter #3 ($response_code) of type int is deprecated in /home/web/public_html/wiki/includes/WebResponse.php on line 42

Warning: Cannot modify header information - headers already sent by (output started at /home/web/public_html/wiki/includes/session/Session.php:48) in /home/web/public_html/wiki/includes/WebResponse.php on line 42

Deprecated: header(): Passing null to parameter #3 ($response_code) of type int is deprecated in /home/web/public_html/wiki/includes/WebResponse.php on line 42

Warning: Cannot modify header information - headers already sent by (output started at /home/web/public_html/wiki/includes/session/Session.php:48) in /home/web/public_html/wiki/includes/WebResponse.php on line 42

Deprecated: header(): Passing null to parameter #3 ($response_code) of type int is deprecated in /home/web/public_html/wiki/includes/WebResponse.php on line 42

Warning: Cannot modify header information - headers already sent by (output started at /home/web/public_html/wiki/includes/session/Session.php:48) in /home/web/public_html/wiki/includes/WebResponse.php on line 42
http://redwolf.ws/wiki/index.php?title=Help:Array&feed=atom&action=history Help:Array - Revision history 2024-05-07T07:49:04Z Revision history for this page on the wiki MediaWiki 1.27.0
Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /home/web/public_html/wiki/includes/db/Database.php on line 1742

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /home/web/public_html/wiki/includes/db/Database.php on line 1742

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /home/web/public_html/wiki/includes/db/Database.php on line 1742

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /home/web/public_html/wiki/includes/db/Database.php on line 1742

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /home/web/public_html/wiki/includes/db/Database.php on line 1742

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /home/web/public_html/wiki/includes/db/Database.php on line 1742
http://redwolf.ws/wiki/index.php?title=Help:Array&diff=8&oldid=prev STrRedWolf: 1 revision(s) 2007-11-11T17:55:39Z <p>1 revision(s)</p> <p><b>New page</b></p><div>{{H:h}}[[Category:Editor handbook]]<br /> &#039;&#039;&#039;Note:&#039;&#039;&#039; The techniques covered in this article depend on features unavailable before MediaWiki 1.6.<br /> This pages explains various methods of creating a kind of [[w:en:associative array|associative array]] using [[Help:Template|templates]].<br /> <br /> The two main array techniques are using [[ParserFunctions#switch:|#switch]], and using a template for each element. The other methods, explained after these, are probably obsolete.<br /> <br /> ==Function #switch==<br /> The function [[ParserFunctions#switch:|#switch]] provides one of the two main array techniques.<br /> <br /> *&lt;nowiki&gt;{{#switch:3|1=Mon|2=Tue|3=Wed|4=Thu|5=Fri|6=Sat|7=Son|undefined}}&lt;/nowiki&gt; gives {{#switch:3|1=Mon|2=Tue|3=Wed|4=Thu|5=Fri|6=Sat|7=Son|undefined}}<br /> *&lt;nowiki&gt;{{#switch:5|1=Mon|2=Tue|3=Wed|4=Thu|5=Fri|6=Sat|7=Son|undefined}}&lt;/nowiki&gt; gives {{#switch:5|1=Mon|2=Tue|3=Wed|4=Thu|5=Fri|6=Sat|7=Son|undefined}}<br /> *&lt;nowiki&gt;{{#switch:0|1=Mon|2=Tue|3=Wed|4=Thu|5=Fri|6=Sat|7=Son|undefined}}&lt;/nowiki&gt; gives {{#switch:0|1=Mon|2=Tue|3=Wed|4=Thu|5=Fri|6=Sat|7=Son|undefined}}<br /> <br /> Using {{timc|Short DOW with switch}}:<br /> *&lt;nowiki&gt;{{Short DOW with switch|3}}&lt;/nowiki&gt; gives {{Short DOW with switch|3}}<br /> *&lt;nowiki&gt;{{Short DOW with switch|5}}&lt;/nowiki&gt; gives {{Short DOW with switch|5}}<br /> *&lt;nowiki&gt;{{Short DOW with switch|0}}&lt;/nowiki&gt; gives {{Short DOW with switch|0}}<br /> <br /> Put &quot;#default=&quot; in front of the default value if it contains &quot;=&quot;:<br /> <br /> *&lt;nowiki&gt;{{#switch:advanced|simple=1+1=2|#default=999+999=1998}}&lt;/nowiki&gt; gives {{#switch:advanced|simple=1+1=2|#default=999+999=1998}}<br /> <br /> ===Limitation===<br /> A serious limitation is the {{mlww|Template limits||pre-expand include size maximum}} of 2,048,000 bytes on the Wikimedia wikis. Inclusion of a single array element adds the size of the whole array to the pre-expand include size. Single use of each array element adds the &#039;&#039;square&#039;&#039; of the number of elements times the size of each element (including the length of the index, and two bytes for the &quot;=&quot; and &quot;|&quot;) to the pre-expand include size. <br /> <br /> For example, in a [[list of Wikipedias]] we can either use a template for the language names in English, {{tim|n en}}, or one for the local language names, {{tim|n local}}, not both: for each of the two, calling it for all languages (about 250) gives a pre-expand include size of more than 1,000,000 bytes, although the expanded wikitext containing both names, and more, is about 100,000 bytes. (In this case the problem can be solved by using parser function #language instead of template &quot;n local&quot;.)<br /> <br /> ==Arrays with a template for each element==<br /> <br /> An array with a template for each element seems primitive compared with using #switch, but an advantage is that this method is much less affected by the {{peisl}}. <br /> <br /> A 1D [[w:en:array|array]] has elements which are templates with names of the form &#039;&#039;array-name&#039;&#039; &#039;&#039;index&#039;&#039;, a 2D array ([[w:en:Matrix (mathematics)|matrix]]) has elements which are templates with names of the form &#039;&#039;array-name&#039;&#039; &#039;&#039;index1&#039;&#039; &#039;&#039;separator&#039;&#039; &#039;&#039;index2&#039;&#039;. The indexes can be any text.<br /> <br /> For example, on Meta there is for each Wikipedia language a template for its English name, e.g. {{tim|eln de}}. They are used on [[List of Wikipedias/sortable]] and can also be useful on similar lists. They replace {{tim|n en}}.<br /> <br /> There is also an older, small collection of templates with names of the form &quot;Lang_name_-_&#039;&#039;language referred to&#039;&#039;_(&#039;&#039;language used&#039;&#039; )&quot; (in fact, the pattern is an example of a generalized form of the name pattern, with a text, here a closing parenthesis, after the second index) with codes used for the two languages; the contents of each template is the word for a language, expressed in the same or another language, e.g. [[Template:Lang name - de (fr)]] contains &quot;Allemand&quot;, which is &quot;German&quot; in French. (See [http://meta.wikimedia.org/w/index.php?title=Special:Allpages/Lang_name&amp;namespace=10 list]; for [[w:en:Main diagonal|diagonal elements]] such as [[Template:Lang name - de (de)]] there are, in addition, copies such as [[Template:Lang name - de]]). See also [[User:Suruena/i18n (en)|explanation page]].<br /> <br /> In the case of a 2D array &#039;&#039;separator&#039;&#039; and the possible values of &#039;&#039;index1&#039;&#039; and &#039;&#039;index2&#039;&#039; should be chosen such that there is no ambiguity; no separator is needed if at least one index is of fixed length, or e.g. if the first index consists of letters and the second of digits. The software does not need to parse &#039;&#039;index1&#039;&#039; &#039;&#039;separator&#039;&#039; &#039;&#039;index2&#039;&#039;, but for convenient human parsing a separator such as a blank space may be preferred in some cases where it is not strictly needed. <br /> <br /> Elements of a 1D array can e.g. be referred to inside a template with &lt;nowiki&gt;{{&lt;/nowiki&gt;&#039;&#039;array-name&#039;&#039; {{{&#039;&#039;index&#039;&#039;}}}}} using parameter &#039;&#039;index&#039;&#039;, or similarly with a variable. Also a page can successively call each array element using &lt;nowiki&gt;{{&lt;/nowiki&gt;&#039;&#039;array-name&#039;&#039; &#039;&#039;index&#039;&#039;}} with varying &#039;&#039;index&#039;&#039;.<br /> <br /> In the case of a 2D array, a template may have a row index as parameter and produce a list based on that row of the matrix, or similarly for columns. See e.g. [[Template:List of Languages]].<br /> <br /> A disadvantage of having a template for each array element is that it is extremely cumbersome to copy a large array to another project, unless a bot is used; a sysop may also apply [[Help:Export and import|export and import]], if those features are enabled.<br /> <br /> An advantage is that the absence of a data value shows up as a link to a non-existing template, allowing an individual data value to be added easily. Depending on how fast the servers are, adding multiple values may be slower, sometimes much slower, than when fewer templates have to be edited.<br /> <br /> ==Array technique using parameter defaults==<br /> {{tim|Short DOW par def}}, based on [[Help:parameter default|parameter default]]s, contains (without the newlines):<br /> <br /> &lt;pre&gt;<br /> {{{if{{{1|u}}}|Mon}}}<br /> {{{if{{{2|u}}}|Tue}}}<br /> {{{if{{{3|u}}}|Wed}}}<br /> {{{if{{{4|u}}}|Thu}}}<br /> {{{if{{{5|u}}}|Fri}}}<br /> {{{if{{{6|u}}}|Sat}}}<br /> {{{if{{{0|u}}}|Son}}}<br /> &lt;/pre&gt;<br /> <br /> &lt;nowiki&gt;{{short DOW par def|ifu=|3=}}&lt;/nowiki&gt; gives {{short DOW par def|ifu=|3=}}<br /> <br /> &lt;nowiki&gt;{{short DOW par def|ifu=|6=|3=|5=|3=}}&lt;/nowiki&gt; gives {{short DOW par def|ifu=|6=|3=|5=|3=}}<br /> <br /> The results are in the index order according to the template content, not in the order of the parameters in the template call. Multiple occurrences are removed.<br /> <br /> See also {{tim|m to ft par def}}.<br /> <br /> ==Array technique using CSS==<br /> Unlike other methods, this method works only for final display, and only on modern browsers with enabled support for [[w:Cascading Style Sheets|CSS]].<br /> The result cannot be used in expressions for template names, parameter names, parameter values, page names in links, etc.<br /> <br /> Example: <br /> <br /> {{tim|Short DOW css d}} contains (without the newlines):<br /> <br /> &lt;pre&gt;<br /> &lt;span style=&quot;display:non{{{1|e}}}&quot;&gt;Mon&lt;/span&gt;<br /> &lt;span style=&quot;display:non{{{2|e}}}&quot;&gt;Tue&lt;/span&gt;<br /> &lt;span style=&quot;display:non{{{3|e}}}&quot;&gt;Wed&lt;/span&gt;<br /> &lt;span style=&quot;display:non{{{4|e}}}&quot;&gt;Thu&lt;/span&gt;<br /> &lt;span style=&quot;display:non{{{5|e}}}&quot;&gt;Fri&lt;/span&gt;<br /> &lt;span style=&quot;display:non{{{6|e}}}&quot;&gt;Sat&lt;/span&gt;<br /> &lt;span style=&quot;display:non{{{0|e}}}&quot;&gt;Sun&lt;/span&gt;<br /> &lt;/pre&gt;<br /> <br /> ;&lt;nowiki&gt;&lt;tt&gt;{{short DOW css d|3=}}&lt;/tt&gt;&lt;/nowiki&gt; gives &lt;tt&gt;{{short DOW css d|3=}}&lt;/tt&gt;<br /> ;&lt;nowiki&gt;&lt;tt&gt;{{short DOW css d|6=|3=|5=|3=}}&lt;/tt&gt;&lt;/nowiki&gt; gives &lt;tt&gt;{{short DOW css d|6=|3=|5=|3=}}&lt;/tt&gt;<br /> ;Without CSS support the result is &lt;tt&gt;MonTueWedThuFriSatSun&lt;/tt&gt;<br /> <br /> Again, the results are in the index order according to the template content, not in the order of the parameters in the template call. Multiple occurrences are removed.<br /> A variant of this method uses the [[MediaWiki:common.css|common.css]] class [[w:WP:HIDE|hiddenStructure]], example: <br /> <br /> {{tim|Short DOW css}} contains (without the newlines):<br /> <br /> &lt;pre&gt;<br /> &lt;span class=&quot;hiddenStructur{{{1|e}}}&quot;&gt;Mon&lt;/span&gt;<br /> &lt;span class=&quot;hiddenStructur{{{2|e}}}&quot;&gt;Tue&lt;/span&gt;<br /> &lt;span class=&quot;hiddenStructur{{{3|e}}}&quot;&gt;Wed&lt;/span&gt;<br /> &lt;span class=&quot;hiddenStructur{{{4|e}}}&quot;&gt;Thu&lt;/span&gt;<br /> &lt;span class=&quot;hiddenStructur{{{5|e}}}&quot;&gt;Fri&lt;/span&gt;<br /> &lt;span class=&quot;hiddenStructur{{{6|e}}}&quot;&gt;Sat&lt;/span&gt;<br /> &lt;span class=&quot;hiddenStructur{{{0|e}}}&quot;&gt;Sun&lt;/span&gt;<br /> &lt;/pre&gt;<br /> <br /> ;&lt;nowiki&gt;&lt;tt&gt;{{short DOW css|3=}}&lt;/tt&gt;&lt;/nowiki&gt; gives &lt;tt&gt;{{short DOW css|3=}}&lt;/tt&gt;<br /> ;&lt;nowiki&gt;&lt;tt&gt;{{short DOW css|6=|3=|5=|3=}}&lt;/tt&gt;&lt;/nowiki&gt; gives &lt;tt&gt;{{short DOW css|6=|3=|5=|3=}}&lt;/tt&gt;<br /> ;Without CSS support the result is &lt;tt&gt;MonTueWedThuFriSatSun&lt;/tt&gt;<br /> <br /> ==Comparison of the CSS method and the parameter default method==<br /> Comparing the CSS method and the parameter default method, we see that each of the lines<br /> <br /> &lt;nowiki&gt;&lt;span style=&quot;display:non{{{3|e}}}&quot;&gt;Wed&lt;/span&gt;&lt;/nowiki&gt;<br /> &lt;nowiki&gt;&lt;span class=&quot;hiddenStructur{{{3|e}}}&quot;&gt;Wed&lt;/span&gt;&lt;/nowiki&gt;<br /> &lt;nowiki&gt;{{{if{{{3|u}}}|Wed}}}&lt;/nowiki&gt;<br /> <br /> in a template T, called with<br /> <br /> &lt;nowiki&gt;{{T|3=}}&lt;/nowiki&gt;<br /> &lt;nowiki&gt;{{T|3=}}&lt;/nowiki&gt;<br /> &lt;nowiki&gt;{{T|ifu=|3=}}&lt;/nowiki&gt;<br /> <br /> respectively, give Wed, and the empty string if 3 is left undefined.<br /> <br /> Thus the parameter default method has similar functionality, but requires an extra parameter. It has the advantage that the result can be used in expressions for template names, parameter names, parameter values, page names in links, etc.<br /> <br /> For comparison, suppose we would use the shorter word &quot;ifu&quot; instead of &quot;HiddenStructure&quot; (note that this would require that class &quot;if&quot; is undefined); then the lines are:<br /> <br /> &lt;nowiki&gt;&lt;span style=&quot;display:non{{{3|e}}}&quot;&gt;Wed&lt;/span&gt;&lt;/nowiki&gt;<br /> &lt;nowiki&gt;&lt;span class=&quot;if{{{3|u}}}&quot;&gt;Wed&lt;/span&gt;&lt;/nowiki&gt;<br /> &lt;nowiki&gt;{{{ if{{{3|u}}}| Wed}}}&lt;/nowiki&gt;<br /> <br /> In the third method the wikitext in the template is 15 characters shorter than the second method, for each optional item, but each call is 5 characters longer.<br /> <br /> In the second method conflicts with other class names have to be avoided, in the third method conflicts with other parameter names. The first method is best in this regard.<br /> <br /> ==Array technique using a small auxiliary template==<br /> Example:<br /> <br /> &lt;nowiki&gt;{{array&lt;/nowiki&gt;<br /> |index=&#039;&#039;index&#039;&#039;<br /> |1=Mon<br /> |2=Tue<br /> |3=Wed<br /> |4=Thu<br /> |5=Fri<br /> |6=Sat<br /> |0=Sun<br /> }}<br /> <br /> using {{tim|array}}, containing &lt;code&gt;&lt;nowiki&gt;{{{{{{index}}}|{{{default|}}}}}}&lt;/nowiki&gt;&lt;/code&gt;.<br /> <br /> In the case of a constant &#039;&#039;index&#039;&#039; this can be useful for selection from predetermined options by a small edit. Alternatively &#039;&#039;index&#039;&#039; can be an expression depending on a variable, or, if the text is in a template, on a parameter.<br /> <br /> Note that if only one template is used, the difference with the method above is that the array data are outside the template: they are provided in the template call.<br /> <br /> Example where the text is in another template (with also a default value): {{tim|short DOW}}, containing:<br /> ----<br /> &lt;pre&gt;{{array<br /> |index={{{1}}}<br /> |1=Mon<br /> |2=Tue<br /> |3=Wed<br /> |4=Thu<br /> |5=Fri<br /> |6=Sat<br /> |0=Sun<br /> |default={{{1}}} is not a valid weekday number.<br /> }}&lt;/pre&gt;<br /> ----<br /> <br /> Examples:<br /> <br /> &lt;code&gt;&lt;nowiki&gt;{{Short DOW|3}}&lt;/nowiki&gt;&lt;/code&gt; gives &lt;code&gt;{{Short DOW|3}}&lt;/code&gt;<br /> <br /> &lt;code&gt;&lt;nowiki&gt;{{Short DOW|{{CURRENTDOW}}}}&lt;/nowiki&gt;&lt;/code&gt; gives &lt;code&gt;{{Short DOW|{{CURRENTDOW}}}}&lt;/code&gt;<br /> <br /> &lt;code&gt;&lt;nowiki&gt;{{Short DOW|7}}&lt;/nowiki&gt;&lt;/code&gt; gives &lt;code&gt;{{Short DOW|7}}&lt;/code&gt;<br /> <br /> <br /> Another version of the two templates could use a term other than &quot;index&quot;, e.g. the empty string. However, it should be a term that itself is not used as array index:<br /> <br /> &lt;code&gt;&lt;nowiki&gt;{{t Short DOW|3}}&lt;/nowiki&gt;&lt;/code&gt; using {{tim|t Short DOW}}, containing:<br /> ----<br /> &lt;pre&gt;{{array<br /> |{{{1}}}<br /> |1=Mon<br /> |2=Tue<br /> |3=Wed<br /> |4=Thu<br /> |5=Fri<br /> |6=Sat<br /> |0=Sun<br /> |default={{{1}}} is not a valid weekday number.<br /> }}&lt;/pre&gt;<br /> ---- (hence using implicit name &quot;1&quot; instead of &quot;index&quot;) gives &quot;&lt;code&gt;{{T Short DOW|3}}&lt;/code&gt;&quot;. The implicit 1=3 is overwritten by &quot;1=Mon&quot;, and &lt;code&gt;{{{Mon}}}&lt;/code&gt; would be produced; since it is undefined, the default is produced, with in this case a confusing error message: not the input is incorrect, but the template itself. <br /> <br /> See also {{tiw|en|switch}}, where parameter names consist of &quot;case: &quot;, followed by the index.<br /> <br /> ===For===<br /> {{tim|for}} allows not only to produce one array element, like above, but also more.<br /> <br /> Examples:<br /> <br /> &lt;code&gt;&lt;nowiki&gt;{{for|call=Short DOW|3}}&lt;/nowiki&gt;&lt;/code&gt; gives &quot;{{for|call=Short DOW|3}}&quot;<br /> <br /> &lt;code&gt;&lt;nowiki&gt;{{for|call=Short DOW|{{CURRENTDOW}}}}&lt;/nowiki&gt;&lt;/code&gt; gives &quot;{{for|call=Short DOW|{{CURRENTDOW}}}}&quot;<br /> <br /> &lt;code&gt;&lt;nowiki&gt;{{for|call=Short DOW|7}}&lt;/nowiki&gt;&lt;/code&gt; gives &quot;{{for|call=Short DOW|7}}&quot;<br /> <br /> &lt;code&gt;&lt;nowiki&gt;{{for|call=Short DOW|sep=-|3|{{CURRENTDOW}}|7}}&lt;/nowiki&gt;&lt;/code&gt; gives &quot;{{for|call=Short DOW|sep=-|3|{{CURRENTDOW}}|7}}&quot;<br /> <br /> &lt;code&gt;&lt;nowiki&gt;{{for|call=Short DOW|6|3|5|3}}&lt;/nowiki&gt;&lt;/code&gt; gives &quot;{{for|call=Short DOW|6|3|5|3}}&quot;<br /> <br /> Compare the array technique using parameter defaults, and (for final display only) that using CSS, both above.<br /> <br /> Differences:<br /> *Above only one template is used instead of three.<br /> *Above the results are in standard index order, here in the order of the parameters in the template call.<br /> *Above multiple occurrences are removed.<br /> <br /> ==See also==<br /> *[[w:en:Portal:Middle-earth/Featured article]] called in [[w:en:Portal:Middle-earth]]: array technique based on [[Help:parameter default|parameter default]]s<br /> *[[Help:Array (older methods)]]<br /> *{{tiw|railway info}}: small example of a method to allow info to be added in a central place (this template, a 1D array with page names as index) displaying the array element concerned on each page.<br /> *[http://wiki.ontoworld.org/wiki/Help:Annotation#Attributes Attribute]: array where each index value is an existing pagename, and the array value is defined on that page using the extension SMW. If the array values are also pagenames (not necessarily existing) the array is called a [http://wiki.ontoworld.org/wiki/Help:Annotation#Relations relation]. Compare:<br /> **&lt;nowiki&gt;{{#switch:3|1=Mon|2=Tue|3=Wed|4=Thu|5=Fri|6=Sat|7=Sun|undefined}}&lt;/nowiki&gt; gives {{#switch:3|1=Mon|2=Tue|3=Wed|4=Thu|5=Fri|6=Sat|7=Sun|undefined}} (see above)<br /> **&lt;ask&gt;weekday number:=3&lt;/ask&gt; giving [[Wednesday]] [http://wiki.ontoworld.org/wiki/Attribute:Weekday_number]<br /> <br /> {{h:f|enname=Array}}</div> STrRedWolf