LOAD_DATASET

[[LOAD_DATASET:setname|delimiter]]

A dataset is any text file with only one key/value pair per line.

setname (string) may either be php$ variable or string value.

delimiter(string) is the separator between the pair’s key name and it’s assigned value.

Example: the data file inventory.txt contains:

color,blue
size,large
name,huckleberry
instock,22
units,lbs

Use the below code to automatically load all the above dataset values into variables with names matching the key names.

[[LOAD_DATASET:inventory|,]]

Display the loaded data.

Color:[[PRINT:color]][[cr]]
Size:[[PRINT:size]][[cr]]
Name:[[PRINT:name]][[cr]]
In Stock:[[PRINT:instock]][[cr]]
Units:[[PRINT:units]][[cr]]

or

[[PRINT:"Color: $color[[cr]]Size: $size[[cr]]Name:$name[[cr]]InStock: $instock[[cr]]Units: $units[[cr]]"]]

After loading, the values may also be accessed by using a php$ array with it’s name matching the dataset’s name and also indexed by the same keys.  example:

<?php echo $inventory['color']; ?>

Leave a Reply