Okay, I'm pretty new to this so it may not even be possible and I'm only doing this this way because I can't get a mySQL version to work but it's been fun working with YAML.
I'm loading this through PHP:
mail:
- 'Crimsonfox: test'
- 'Crimsonfox: Test2'
- 'Crimsonfox: t'
socialspy: false
nickname: Crimsonfox
muted: false
inventory:
size: 0
godmode: false
teleportenabled: true
afk: true
jailed: false
lastlocation:
yaw: 176.81152
pitch: 36.900253
z: 2744.016947782735
y: 67.0
world: C3P0
x: 835.7719458699837
What I'm trying to do is adding a new mail entry in, I do my PHP stuff and it dumps this:
mail: null
0: 'TestyMcgee: And his message'
1: 'Crimsonfox: test'
2: 'Crimsonfox: Test2'
3: 'Crimsonfox: t'
socialspy: false
nickname: Crimsonfox
muted: false
inventory:
size: 0
godmode: false
teleportenabled: true
afk: true
jailed: false
lastlocation:
yaw: 176.81152
pitch: 36.900253
z: 2744.0169477827
y: 67
world: C3P0
x: 835.77194586998
No dashes anymore but instead numbers with colons. And some of the spacing lower down has changed. I doubt I'm experienced enough to figure it out, thought I'd did quite well to insert that mail in but then it breaks when it reads the YML file because it's in a slightly different format.
Any help would be appreciated.
Here's the PHP if it helps:
<?php
require_once 'lib\sfYaml.php';
echo '<pre>';
$array = sfYaml::load('crimsonfox.yml');
$test = array_key_exists ('mail', $array);
echo $test;
$test2 = array_search ('mail', $array);
echo $test2.'Blergh<br />';
array_keys($array, '0',true);
$CountMail = array();
$i = 0;
$done = false;
$offset = 0;
foreach ($array as $key_name => $key_value) {
if (is_numeric($key_name)) {
echo "BLERGH";
if ($done == false) {
$offset = array_search(strval($key_name), array_keys($array));
$done = true;
echo 'The first mail key offset is:<font color="red">' . $offset . '</font>';
}
$i++;
}
print " Key = " . $key_name . " Value = " . $key_value . "<BR>";
}
echo $i;
echo '<br />';
print_r($array);
echo '<br /><br />';
echo $array['1'].'<br /> ';
$message = "TestyMcgee: And his message";
array_splice ( $array , $offset, 0, $message);
$yaml = sfYaml::dump($array, 2);
file_put_contents('CrimsonTest.yml', $yaml);
print_r($array);
?>