Maybe somebody can help me?
file_put_contents and fopen does not work for my and I donīt know what happen :S
Abstract:
1. I need read a random line in a txt hosted in a FTP
2. I need delete this randome line from that txt
3. Next I need put the extracted random line in another txt (not coded yet)
Here is my code:
Expand|Select|Wrap|Line Numbers
- /***************************************/
- $file = "ftp://USER:PASS@ftp.myftp.x10.bz/words2.txt";
- $lines = count(file($file));
- $topic = explode("\n", file_get_contents($file));
- $random = rand(0,$lines);
- $random_topic = $topic[$random];
- unset($topic[$random]);
- file_put_contents($file, implode('', $topic), LOCK_EX);
- /****************************************/
file_put_contents($file, "sometext", FILE_APPEND);
AND
$fh = fopen("$file", "w");
fwrite($fh, "sometext");
fclose($fh);
But those does not work. I put this file 0777 permitions and does not work :S
Someone knows what happening?
PHPversion: 5
Host: http://www.x10hosting.com/
Thanks in advance.
Regards