[PHP] rewriting a line in a text file

2002-09-12 Thread drparker

hi - i have a text file that i am using as a database.  the format for
each line is such (2 lines shown):

Fashion|508|Text Text
Text.|http://qtbras.com/qtbrascat/images/508_big.jpg|http://qtbras.com/qtbrascat/images/508_thumb.jpg

Fashion|510|Text Text
Text|http://qtbras.com/qtbrascat/images/510_big.jpg|http://qtbras.com/qtbrascat/images/510_thumb.jpg

I'm putting each line into an array, then splitting each value by the
pipe symbol to get individual values.  i need to know how to select a
line in the text file and rewrite over it - for example if i wanted to
replace:

Fashion|510|Text Text
Text|http://qtbras.com/qtbrascat/images/510_big.jpg|http://qtbras.com/qtbrascat/images/510_thumb.jpg

with:

Allure|533|Text Text
Text|http://qtbras.com/qtbrascat/images/510_big.jpg|http://qtbras.com/qtbrascat/images/510_thumb.jpg

or something like that, how do i select which line in the text file i
want to replace and write over it?  i would prefer not to delete the
line and then write a new one at the end, but if that's the only way,
i'll do it.

thanks


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




Re: [PHP] rewriting a line in a text file

2002-09-12 Thread Kumar Lakshminarayanan

Try using an unique number as the first field of the line.
You can then use that number to select the line (entry) and update it.
Kumar

drparker wrote:

 hi - i have a text file that i am using as a database.  the format for
 each line is such (2 lines shown):

 Fashion|508|Text Text
 
Text.|http://qtbras.com/qtbrascat/images/508_big.jpg|http://qtbras.com/qtbrascat/images/508_thumb.jpg

 Fashion|510|Text Text
 
Text|http://qtbras.com/qtbrascat/images/510_big.jpg|http://qtbras.com/qtbrascat/images/510_thumb.jpg

 I'm putting each line into an array, then splitting each value by the
 pipe symbol to get individual values.  i need to know how to select a
 line in the text file and rewrite over it - for example if i wanted to
 replace:

 Fashion|510|Text Text
 
Text|http://qtbras.com/qtbrascat/images/510_big.jpg|http://qtbras.com/qtbrascat/images/510_thumb.jpg

 with:

 Allure|533|Text Text
 
Text|http://qtbras.com/qtbrascat/images/510_big.jpg|http://qtbras.com/qtbrascat/images/510_thumb.jpg

 or something like that, how do i select which line in the text file i
 want to replace and write over it?  i would prefer not to delete the
 line and then write a new one at the end, but if that's the only way,
 i'll do it.

 thanks

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



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