User Tools

Site Tools


uphp:functions:ini_put_array

ini_put_array

WMPRO, WMMINI FW >= 1.0 WMMEGA FW >= 2.0

Write a group of parameters to an INI file from an array

Description

ini_put_array ( string $filename, array $data [, string $section ] )

This function writes multiple configuration key/value pairs to an INI file. Values can be written to a single section if the optional section is specified (provide a single-dimensional array). Values can be written to one or more sections if section is not specified (provide a two-dimensional array).

Parameters

$filename: Full path and name of the INI file

$data: Array of key/value elements to write

  • If section is specified, a single-dimensional array should be provided (to write values only to one section).
  • If section is not specified, a two-dimensional array can be provided, where the first dimension contains the sections and the second the key/value pairs (to write values in one or more sections).

$section: Optional, name of the section inside the INI file (provide the data as a single-dimensional array)

Return Values

None

Examples

Single-dimensional array, section specified

<?
  $arr=array();
  $arr['name']="John";
  $arr['age']=33;
  ini_put_array("/ini_put_array_example.ini",$arr,"settings");
?>

The INI file will contain:

[settings]
name=John
age=33

Two-dimensional array, section NOT specified

<?
  $arr=array();
  $arr['data']=array();
  $arr['data']['name']="Jeff";
  $arr['data']['age']=39;
  $arr['address']=array();
  $arr['address']['city']="Rayville"
  $arr['address']['country']="USA"
  ini_put_array("/ini_put_array_example.ini",$arr);
?>

The INI file will contain:

[data]
name=Jeff
age=39
[address]
city=Rayville
country=USA

See Also

ini_get() - Get a value from an INI file

ini_get_array() - Get a group of parameters from an INI file as an array

ini_set() - Set a value in an INI file

uphp/functions/ini_put_array.txt · Last modified: 2021/09/13 05:57 (external edit)