Hi,

At start test.txt contains a serialized array with value "one" and "two".
a:2:{i:0;s:3:"one";i:1;s:3:"two";}
after one run this is:
a:3:{i:0;s:3:"one";i:1;s:3:"two";i:2;s:4:"tree";}

But the last row prints nothing. Why?

Tnx,

Bas 

<?
$array=array();
$fp=fopen("test.txt","r");
flock($fp,1);
$array=unserialize(fread($fp,filesize("test.txt")));
flock($fp,3);
fclose($fp);

array_push($array,"tree");

$fp=fopen("test.txt","w+");
flock($fp,2);
fwrite($fp,serialize($array));
flock($fp,3);
fclose($fp);

$fp=fopen("test.txt","r");
flock($fp,1);
$array=unserialize(fread($fp,filesize("test.txt")));
flock($fp,3);
fclose($fp);

echo $array[0].$array[1].$array[2];
?>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to