|
Hi,
I am building a web site and have all the text titles in a file called texts.php and I want to be able to add new texts a the end of file one line before the ?>.
so:
How can I read all the file?
Remove the ?> from the end of the file?
writing new line(s) at the end of the file?
Adding new ?> at the end again
here is the file:
<?php
// main texts December 25, 2005
$lang['sitename']= 'MySite.com';
$lang['siteurl']= 'http://mysite.com';
$lang['click_here']='Click Here';
?>
=========================================
here is what I have done:
This file can read but I can't get the contents outside this code and use somewhere else in a function:
$repl="\n";
$special = "\?>";
$handle = @fopen("$myfile", "r") or die("can not find the file to read");
while (!feof($handle)) {
$buffer = fgets($handle, 4096);
//echo $buffer ;
$samm =ereg_replace($special,$repl, $buffer);
echo $samm;
}// end of while
fclose($handle);
I can get the contents within the while { .....} only.
Please help.
|