ini_read_real

You can use this function to read a number 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_real(section, key, default);

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

 

Returns:

Real

 

Example:

ini_open("savedata.ini");
score = ini_read_real("save1", "score", 0 );
ini_close();

This will open "savedata.ini" and set score to the value under "save1" > "score" in it, then close the .ini again. Should there be no value under "save1" > "score", or there no "savedata.ini" file present, score will be set to 0.