ini_read_string

You can use this function to read a string (text) from an INI data file.

INI files are split into sections and then each section is subsequently split into key - value pairs. So a typical INI file would look something like this: 

Ini file contents example

 

Syntax:

ini_read_string(section, key, default);

ArgumentTypeDescription
sectionStringThe section of the .ini to read from.
keyStringThe key within the relevant section of the .ini to read from.
defaultStringThe string to return if a string is not found in the defined place (or the .ini file does not exist). Must be a string.

 

Returns:

String

 

Example:

ini_open("savedata.ini");
global.name = ini_read_string("player", "name", "Player1");
ini_close();

This will open "savedata.ini" and set global.name to the string under "save1" > "Name" in it, then close the .ini again. If there is no string under "save1" > "Name", or no file named "savedata.ini" is present, global.name will be set to "Player1".