Page 2 of 2
Posted: Mon Aug 19, 2002 2:04 pm
by Silver_Eclipse
is that even possible?
Posted: Mon Aug 19, 2002 7:52 pm
by Silver_Eclipse
surely someone knows how this can be done?
Posted: Tue Aug 20, 2002 6:50 am
by twigletmac
Posted: Tue Aug 20, 2002 1:55 pm
by Silver_Eclipse
yeah i have to do it using files because i dont have access to the database(if they even have one) of the site this is for.
Posted: Tue Aug 20, 2002 3:33 pm
by hob_goblin
you could easily either:
a) if the content you want changed is on it's own line, to what mac said
b) read the file into a string using fread, and use preg_replace() eregi_replace() ereg_replace() or str_replace() to replace the contents.
Posted: Tue Aug 20, 2002 5:05 pm
by Silver_Eclipse
so if i searched the file for a specific piece then i could use hobgoblins original post to have it remove/replace all of the sections that match that pattern or something?
Posted: Tue Aug 20, 2002 10:21 pm
by Silver_Eclipse
it may seem like im having you guys make my site for me but these things i have been asking are only pieces of my whole code, and some of the solutions worked for me some don't so i am still trying to getmy last question fixed. after i figure that out then all i should have left is to find out how i can have it save the information to a file at a certain time each day.
Posted: Tue Aug 20, 2002 10:25 pm
by Silver_Eclipse
Code: Select all
<?php
$file = file("http://");
$filename = "chart.txt";
$fe = fopen ($filename, "a+");
$ff = fread ($fe, 70000);
$userfile = "users.txt";
$users = fopen ($userfile, "r");
$userread = fread ($users, 100);
$table = "</TABLE>";
$date = date('\T\o\d\a\y \i\s l F j, Y, g:i A');
$a = 64;
$b = $userread;
$sub = 64 + 196;
$sub2 = $b + 2;
$final = $sub2 * 14 + $sub;
include 'style.css';
include 'header.php';
print "<TABLE width=100% border bordercolor='#009999' cellspacing='0'>";
while(list($array) = each($file)){
if ($array > $a and $array < $final){
print $fileї$array];
}
}
print $table;
print "<center>$date</center>";
?>
while(list($array) = each($file)){
if ($array > $a and $array < $final){
print $file[$array];
right after the if ($array > $a and $array < $final)
i want to replace some lines from that array with different ones, and id like to do it with a pattern so that every line that matches my pattern will be replaced with what i choose before i print them and then print it after everything is replaced to produce the final output.
Posted: Wed Aug 21, 2002 12:58 am
by Silver_Eclipse
ok so i managed to replace the lines with ereg_replace() but i cant figure out a way to specify a limit like the if ($array > $a and $array < $b); thing so that i can make all the lines past a certain point get replaced and the rest stay the same. i also have to find a way to do that because preg_replace doesnt appear to be working as it either replaces every single line with the code, or gives me a '(' unknown modifier error message. (and yes i have been looking in the manual but there are so many functions that its hard to find soemthing that will do what you want it to) and i have tested eregi as well and it seems to work too.