PHP parse_ini_string()関数
❮PHPファイルシステムリファレンス例
ini文字列を解析します。
$ini = '
[names]
me = "Robert"
you = "Peter"
[urls]
first = "http://www.example.com"
second = "https://www.w3schools.com"
';
print_r(parse_ini_string($ini));
上記のコードの出力は次のようになります。
Array
(
[names] => Array
(
[me] => Robert
[you] => Peter
)
[urls] => Array
(
[first] => http://www.example.com
[second] => https://www.w3schools.com
)
)
定義と使用法
parse_ini_file()関数は、構成(ini)文字列を解析し、設定を返します。
ヒント:この関数は、独自の構成ファイルを読み込むために使用でき、php.iniファイルとは関係ありません。
注:次の予約語をiniファイルのキーとして使用しないでください:null、yes、no、true、false、on、off、none。さらに、次の予約文字をキーに使用しないでください:{} |&〜!()^ "。
構文
parse_ini_string(ini, process_sections, scanner_mode)
パラメータ値
Parameter | Description |
---|---|
ini | Required. Specifies the ini file to parse |
process_sections | Optional. If set to TRUE, it returns is a multidimensional array with section names and settings included. Default is FALSE |
scanner_mode |
Optional. Can be one of the following values:
|
技術的な詳細
戻り値: | 成功した場合は配列、失敗した場合はFALSE |
---|---|
PHPバージョン: | 5.3+ |
❮PHPファイルシステムリファレンス