RE: Writing to a file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I can't write the entire file.  The page has Design Time Controls.  If I rewrite the entire page this controls get messed up.  I only want to search for the CSS link in the html header and change it to the correct CSS link.



Here is a snippet of the code

---

	// loop through the file
	while( ! feof ($fd) )
	{	
		$buffer = fgets($fd);
		$aRetVal = parse_css($buffer, $path, $css, $aRetVal);

		if( sizeof($aRetVal) == 2 )
		{	
			fwrite( $fd, $aRetVal[0] );
			break;
		}

--

-----Original Message-----
From: Mike Brum [mailto:php@crazyted.com]
Sent: Thursday, September 25, 2003 3:11 PM
To: Gerardo Rojas; php-windows@lists.php.net
Subject: RE:  Writing to a file


I guess this all depends on how you're writing to the file. Without code,
I'm not sure what the specific problem is.

One way to do this would be to read the file into an array and replace the
line in that array. Then, write the newly constructed array to file. This
way, at write time, the former data no longer exists.

-M

-----Original Message-----
From: Gerardo Rojas [mailto:grojas@strategicinc.com] 
Sent: Thursday, September 25, 2003 2:09 PM
To: php-windows@lists.php.net
Subject:  Writing to a file


I'm am able to open the file read and write to it.  The problem is that I
want to replace a line of text with another line.  My function is actually
writing my new line after the line I wanted to change.  Can we do arithmetic
on the $fd (file handle or file descriptor)?  To tell PHP to write where (
$fd - 1 ) points to?



--
Gerardo S. Rojas
mailto: grojas@strategicinc.com

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



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux