Reading elements from $file
to array, return value of array[0]
then delete element and save array to file
unset is not working, why ?
here is code:
list.txt - file(1kb) 10 lines.
function files($files)
{
$list = array();
$list = file($file) or die('read error');
print_r($list); //debug
unset($list[0]);
$f = fopen($file, 'w+');
flock($f, LOCK_EX);
foreach ($list as $string) {
fwrite($f, $string);
}
print_r($list); // debug
flock($f, LOCK_UN);
fclose($f);
return $s = ($list[0]);
}
You return a value before your unset-statement:
Try