Editing Module:Array

Warning: You are not logged in. Once you make an edit, a temporary account will be created for you. Learn more. Log in or create an account to continue receiving notifications after this account expires, and to access other features.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision Your text
Line 40: Line 40:
-- split string to array
-- split string to array
local array = lib.split(arrayString, separator, split_opt)
local array = lib.split(arrayString, separator, split_opt)
local array2 = args.array2 and lib.split(args.array2, args.arraysep2 or separator, split_opt) or nil
if array2 then
local product = {}
for _, item1 in ipairs(array) do
for _, item2 in ipairs(array2) do
table.insert(product, {item1, item2})
end
end
array = product
end


-- remove duplcates from array
-- remove duplcates from array
Line 65: Line 54:
for key, value in pairs(array) do
for key, value in pairs(array) do
local item = form
local item = form
local value2
if array2 then
value2 = value[2]
value = value[1]
end
item = item:gsub('{newline}', '\n')
item = item:gsub('{newline}', '\n')
item = item:gsub('{index}', key)
item = item:gsub('{index}', key)
Line 90: Line 72:
split(values, '2')
split(values, '2')
if value2 then item = item:gsub('{item2}', value2) end
item = item:gsub('{item}', value)
item = item:gsub('{item}', value)
item = item:gsub('{item([%d%.]*)}',
item = item:gsub('{item([%d%.]*)}',
Please note that all contributions to The Petit Planet Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see Petit Planet Wiki: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:||}}
{{#ifeq:|||}}
{{#expr:}}
{{#switch:||#default=}}
{{#replace:||}}
{{#titleparts:}}
{{#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&mdash;&nbsp;&comma;&shy;