LUA

Use PHP Functions in LUA Code

explode
Based on [PHP explode]
Example: explode(” and “,”one and two and three and four”) –> {“one”,”two”,”three”,”four”}
Compatibility: Lua 5.0 and 5.1function explode(div,str)
if (div==”) then return false end
local pos,arr = 0,{}
— for each divider found
for st,sp in function() return string.find(str,div,pos,true) end do
table.insert(arr,string.sub(str,pos,st-1)) — Attach chars left of current divider
pos = sp + 1 — Jump past current divider
end
table.insert(arr,string.sub(str,pos)) — Attach chars right of last divider
return arr
endimplode
Based on [PHP implode]Use table.concat:

PHP implode(join,array) is equivalent to Lua table.concat(table,join)

PHP: implode(” “,array(“this”,”is”,”a”,”test”,”array”)) –> “this is a test array”

Lua: table.concat({“this”,”is”,”a”,”test”,”array”},” “) –> “this is a test array”

Reference – http://lua-users.org/wiki/MakingLuaLikePhp

Read More...