This is the code i currently have:
$item = "$item";
$list = "items.txt";
$oldword = "$item ~n";
$results = file($list);
$newword = "(No Item) ~n";
while (list(,$path) = each($results)){
$parts = explode(':', $path);
$path = $parts[0];
$fp = fopen("$list", 'r');
if ($fp){
$data = fread($fp, filesize($list));
fclose($fp);
$newdata = str_replace($oldword, $newword, $data);
$fp = fopen($list, 'w');
if ($fp){
fwrite($fp, $newdata);
fclose($fp);
}
}
}
This code works almost perfect accept for when it replaces the string, and if the string it replaces with is bigger string it will cut out the extra letters.
Example if in the text file you have:
pig ~n
dog ~n
cat ~n
some animal ~n
Once you replace "pig" with "(No Item) ~n" the text file will say:
(No Item) ~n
dog ~n
cats ~n
some (it erases up to the space)
Hope this problem is solvable, please note the text file will be changing size often. I was thinking maybe i might have to use a sorter replacer then "(No Item)" like "no" instead.
Thanxs for the help and have a great day,
DarkBoy