hi, im trying to save an all time high score and a daily high score for a flash game i made. the second score is the daily high that gets reset to zero each day. so heres the script that gets run daily...
<?php
// Read the file in
$oscores = file (scores/highscores.sco);
// Break out the data into a new 2-d array called $tscores
for ($i = 0; $i < 2; $i++)
{
$g = unserialize($oscores[$i]);
$tscores[$i][0] = $g[0];
$tscores[$i][1] = $g[1];
}
// Clear Second Score
$tscores[1][0] = 0;
$tscores[1][1] = "";
$file=fopen("scores/highscores.sco", "w");
// Write them out
for ($i = 0; $i < 2; $i++)
{
$st = serialize($tscores[$i]) . "\n";
fputs($file, $st);
}
fclose($file);
?>
the problem is that if i start out with an entry like this in my "highscores.sco" file...
a:2:{i:0;i:50;i:1;s:6:"gfdshh";}
a:2:{i:0;i:50;i:1;s:6:"gfdshh";}
i end up with this after the script runs...
a:2:{i:0;N;i:1;N;}
a:2:{i:0;i:0;i:1;s:0:"";}
as you can see the second score gets reset but it blows out the first score with the N's which isnt good. so my question is how do i make it keep the original first score intact? [ive tried only unserializing the second score to reset it and not touching the first score but when i put it back in it totally deletes the first score]
please help... thanks.