Page 1 of 1

Problems with file writing

Posted: Sat Apr 28, 2007 3:35 pm
by staar2
I have problems with this function, it dosent want to work, it returns empty array.

Code: Select all

function deleteLine($line_num) {
			$content = $this->readFile();
			unset($content[$line_num]);
			
			$fp = fopen($this->filename, 'w+');
			
			flock($fp, LOCK_EX);
			foreach ($content as $line) {
				fwrite($fp, $line, 4029);
			}
			flock($fp, LOCK_UN);
			fclose($fp);
			
		}
:?

Posted: Sat Apr 28, 2007 4:45 pm
by feyd
It doesn't "return" anything. How are you finding an empty array? The function result, if stored, would be null.

Posted: Wed May 02, 2007 12:51 am
by neel_basu
You should use return true or false in this type of function.