OpenersPrimaryExamplesSection(Spacer1)Examples  (9)

OpenersExampleSection0(Spacer1)Basic Examples  (9)

Export an association as a section with properties:

ExportString[<|"PHP"-><|"max_execution_time" -> 30, "max_input_time"->60, "memory_limit"->"128M"|>|>, "PHPIni"]

Create a file:

file = CreateFile[];

Add a section and an element to it:

WriteString[
file, "
[PHP]
engine = On
"];

Import it as a PHPIni file:

Import[file, "PHPIni"]

Create a file:

file = CreateFile[];

Write properties and comments to it:

WriteString[file, "
[PHP]
; ...
[PDO]
pdo_mysql.default_socket = /path/to/mysql.sock
[PostgresSQL]
; Allow or prevent persistent links.
pgsql.allow_persistent = On   ; On | Off
"];

Import the data only, as an (RefLink[Association, paclet:ref/Association]):

Import[file, "PHPIni"]

Import the data and the commented lines:

Import[file, {"PHPIni", "CommentedData"}]

If no section was defined, elements are associated to the key None:

ImportString["global_key = global_value ", "PHPIni"]

PHPIni represents lists as a PHP array:

ExportString[<|"MyApp"-> <|"SpecialDays" -> {"Monday","Tuesday","Friday"}|>|>, "PHPIni"]

PHPIni represents associations as a PHP map:

ExportString[<|"MyApp"-><|"db_config"-><|"User"->"root", "host"->"localhost", "port"->"5678"|>|>|>, "PHPIni"]

Sections must start with the character "[" and finish with "]":

ImportString[" [section]", "PHPIni"]

Commented lines must start with the character ";":

ImportString[" ; comments", "PHPIni"]

TakeDrop[{1,2,3,4},2]

Arbitrary expressions are converted to strings:

ExportString[<|"GeoData" -> <|"default_position"->GeoPosition[(Entity["Paris", Entity["City",{"Paris","IleDeFrance","France"}], "Entity[\"City\", {\"Paris\", \"IleDeFrance\", \"France\"}]", "city"])]|>|>, "PHPIni"]

It is possible to build a PHPIni configuration file with commented elements:

ExportString[{None->{""," This file is a PHPIni configuration file.",""},"section1"->{"key1"-><|"Value"->"element1 ", "Comment"->" this is the first element"|>}},"PHPIni"]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {Related Formats:  (RefLink[Ini, paclet:ref/format/Ini])  ▪  (RefLink[JavaProperties, paclet:ref/format/JavaProperties])  ▪  (RefLink[CSV, paclet:ref/format/CSV])  ▪  (RefLink[TSV, paclet:ref/format/TSV])  ▪  (RefLink[ApacheLog, paclet:ref/format/ApacheLog])  ▪  (RefLink[Text, paclet:ref/format/Text])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Listing of All Formats, paclet:guide/ListingOfAllFormats])}, {▪(RefLinkPlain[Systems & Utility Formats, paclet:guide/SystemsAndUtilityFormats])}, {▪(RefLinkPlain[Web Formats, paclet:guide/WebFormats])}})}})