ini.save(file, table)

Encode a Lua table to ini format and save it to a file.

Parameters

file

A File object or a filename string, representing the file to save the ini data.

table

The table to be encoded to ini format and saved to the file. The table must follow the following rules :
  • The table must contain only string keys, each with an associated sub-table
  • Each sub-table must contain only pairs of string keys and string or number values

Return value

Returns true or false in case of error.

Example

local ini = require "ini" local t = { user1 = { name = "John", age = 38, sex = "male" }, user2 = { name = "Jane", age = 26, sex = "female" } } -- save the table content to a file in ini format ini.save("test.ini", t)