Ask about general coding issues or problems here.
Moderators: macek, egami, gesf
by GeOrGe » Fri Jul 19, 2002 1:04 am
- Code: Select all
$filename = "./conf.php";
$fd = fopen ($filename, "r");
$DELETE = "//start_entry1";
echo"$DELETE";
$m_line=3;$tmp_line=0;$line=0;
$m_filename = "./conf2.php";
$m_fd = fopen($m_filename, "w");
while (!feof ($fd)){
$buffer = fgets($fd, 4096);
$pos = strpos ($buffer, $DELETE);
if ($pos === false and $line==0){
fputs ($m_fd,$buffer);
}
else{
if ($tmp_line < $m_line){
$tmp_line = $tmp_line + 1;
$line = 1;
}
else{
$line = 0;
}
}
}
fclose($fd);
fclose($m_fd);
copy("./conf2.php","./conf.php");
No need of //end_entry1
-
GeOrGe
- New php-forum User

-
- Posts: 6
- Joined: Thu Jul 18, 2002 11:56 pm
by WiZARD » Fri Jul 19, 2002 1:23 am
GeOrGe wrote:- Code: Select all
$filename = "./conf.php";
$fd = fopen ($filename, "r");
$DELETE = "//start_entry1";
echo"$DELETE";
$m_line=3;$tmp_line=0;$line=0;
$m_filename = "./conf2.php";
$m_fd = fopen($m_filename, "w");
while (!feof ($fd)){
$buffer = fgets($fd, 4096);
$pos = strpos ($buffer, $DELETE);
if ($pos === false and $line==0){
fputs ($m_fd,$buffer);
}
else{
if ($tmp_line < $m_line){
$tmp_line = $tmp_line + 1;
$line = 1;
}
else{
$line = 0;
}
}
}
fclose($fd);
fclose($m_fd);
copy("./conf2.php","./conf.php");
No need of //end_entry1
Hi!
I think what you need create array from your file and delete id from array it's faster variant than you propose, but if file too big you have a problem with speed your maschine
-

WiZARD
- Moderator

-
- Posts: 1257
- Joined: Thu Jun 20, 2002 10:14 pm
- Location: Ukraine, Crimea, Simferopol
-
Return to PHP coding => General
Who is online
Users browsing this forum: Google [Bot], machachar and 3 guests