REMPTY
REMPTY = "\0\0\0\0\0"
The Simple PHP YAML Class.
This class can be used to read a YAML file and convert its contents into a PHP array. It currently supports a very limited subsection of the YAML spec.
Usage:
$Spyc = new Spyc;
$array = $Spyc->load($file);
or:
$array = Spyc::YAMLLoad($file);
or:
$array = spyc_load_file($file);
YAMLLoad(string $input) : array
Load YAML into a PHP array statically
The load method, when supplied with a YAML stream (string or file),
will do its best to convert YAML in a file into a PHP array. Pretty
simple.
Usage:
$array = Spyc::YAMLLoad('lucky.yaml');
print_r($array);
string | $input | Path of YAML file or string containing YAML |
YAMLLoadString(string $input) : array
Load a string of YAML into a PHP array statically
The load method, when supplied with a YAML string, will do its best to convert YAML in a string into a PHP array. Pretty simple.
Note: use this function if you don't want files from the file system loaded and processed as YAML. This is of interest to people concerned about security whose input is from a string.
Usage:
$array = Spyc::YAMLLoadString("---\n0: hello world\n");
print_r($array);
string | $input | String containing YAML |
YAMLDump(array $array, integer $indent = false, integer $wordwrap = false, integer $no_opening_dashes = false) : string
Dump YAML from PHP array statically
The dump method, when supplied with an array, will do its best to convert the array into friendly YAML. Pretty simple. Feel free to save the returned string as nothing.yaml and pass it around.
Oh, and you can decide how big the indent is and what the wordwrap for folding is. Pretty cool -- just pass in 'false' for either if you want to use the default.
Indent's default is 2 spaces, wordwrap's default is 40 characters. And you can turn off wordwrap by passing in 0.
array | $array | PHP array |
integer | $indent | Pass in false to use the default, which is 2 |
integer | $wordwrap | Pass in 0 for no wordwrap, false for default (40) |
integer | $no_opening_dashes | Do not start YAML file with "---\n" |
dump(array $array, integer $indent = false, integer $wordwrap = false, $no_opening_dashes = false) : string
Dump PHP array to YAML
The dump method, when supplied with an array, will do its best to convert the array into friendly YAML. Pretty simple. Feel free to save the returned string as tasteful.yaml and pass it around.
Oh, and you can decide how big the indent is and what the wordwrap for folding is. Pretty cool -- just pass in 'false' for either if you want to use the default.
Indent's default is 2 spaces, wordwrap's default is 40 characters. And you can turn off wordwrap by passing in 0.
array | $array | PHP array |
integer | $indent | Pass in false to use the default, which is 2 |
integer | $wordwrap | Pass in 0 for no wordwrap, false for default (40) |
$no_opening_dashes |
_yamlize( $key, $value, $indent, $previous_key = -1, $first_key, $source_array = null) : string
Attempts to convert a key / value array item to YAML
$key | The name of the key |
|
$value | The value of the item |
|
$indent | The indent of the current node |
|
$previous_key | ||
$first_key | ||
$source_array |
_dumpNode( $key, $value, $indent, $previous_key = -1, $first_key, $source_array = null) : string
Returns YAML from a key and a value
$key | The name of the key |
|
$value | The value of the item |
|
$indent | The indent of the current node |
|
$previous_key | ||
$first_key | ||
$source_array |