سانچہ:Array/doc

< سانچہ:Array
نظرثانی بتاریخ 16:37، 24 مئی 2022ء از ur>Wikivahdat (add categories and navbox; minor amendments)
(فرق) → پرانا نسخہ | تازہ ترین نسخہ (فرق) | تازہ نسخہ ← (فرق)

This template will allow manipulation or retrieve properties of an array list with a designated separator. It handles three functions: count, get and pos.

Usage

{{Array|<Function>|<Array items>|<Separator>|<Property>|Parameters (optional)}}

5th parameter only valid with pos function when limiting multiple outputs to a single position.

Functions

Count

Will count the total number of items in the array using the designated separator. Leading or trailing separators will be stripped out.

  • {{Array|count|This is my array| }} → 4
  • {{Array|count|An,array,separated,by,commas|,}} → 5
  • {{Array|count|,An,array,with,trailing,commas,|,}} → 5
Get

Will get the Nth item in the array.

  • {{Array|get|My,wiki,test,array|,|3}} → test
  • {{Array|get|A.list.of.dot.separated.items|.|2}} → list
  • {{Array|get|A sentence of typical words| |5}} → words
Pos

Will retrieve the Nth position of the search item. If duplicates are found, will output all results with the designated separator. Output can be limited by specifying a 5th parameter. Can be used as true or false if output exists to determine if a match exists.

Do not use the ^ character as this is used as a placeholder.

  • {{Array|pos|A sentence of typical words| |sentence}} → 2
  • {{Array|pos|A.wiki.test.string.in.a.test.array|.|unmatched}}
  • {{Array|pos|A.wiki.test.string.in.a.test.array|.|test}} → 3.7
  • {{Array|pos|Position,of,the,second,test,in,a,test,array|,|test|2}} → 8
  • {{Array|pos|2,4,6,6,7,11,12|,|7}} → 5
  • {{Array|pos|2,4,6,6,7,11,12|,|6|2}} → 4


See also