thanks, but can u help me 'automatically' do it and somehow use preg_replace or str_replace?
Printable View
thanks, but can u help me 'automatically' do it and somehow use preg_replace or str_replace?
'automatically' based on what?
acutrally..
when a website is visited, then it will delete text.
Ok, I see the connection now. That is code I gave you before right? Not sure how to test this so...it is untested
PHP Code:<html>
<head>
</head>
<body>
<?php
$affiliate = 'somesite.com'; //Don't add anything that isn't ALWAYS in the URL
if(strpos(strtolower($_SERVER['HTTP_REFERER']),$affiliate) !== false){
$add = $affiliate;
}
else{
$del = $affiliate;
}
if(!empty($del)){
$file = file('list.txt');
ob_start();
for($i=0;$i < count($file);$i++){
if(rtrim($file[$i]) != $del){
echo $file[$i];
}
}
$write = ob_get_contents();
ob_end_clean();
$handle = fopen('list.txt','w');
fwrite($handle,$write);
fclose($handle);
}
else if(!empty($add)){
$handle = fopen('list.txt','a');
fwrite($handle,$add."\n");
fclose($handle);
}
?>
</body>
</html>
Ok, yeah list.txt needs to look like this
Code:dynamicdrive.com
digg.com
yahoo.com
google.com
ebay.com
what will this delete? Only the url, right?
i want it to delete some text after the url. hope im not bothering you with all my questions
Quote:
Originally Posted by me
So, I repeat. what does the file look like exactly?Quote:
Originally Posted by cursed
Code:<a href="http://www.urlhere.com">Test</a> <BR> Description: A test website about blah.
Here I've written a function to do what you want. I'll leave it up to you to determine how to use it.PHP Code:<?php
function deleteline($del,$filename){
$file = file($filename);
ob_start();
for($i=0;$i < count($file);$i++){
if(strpos($file[$i],$del) === FALSE){
echo $file[$i];
}
}
$write = ob_get_contents();
ob_end_clean();
$handle = fopen('list.txt','w');
fwrite($handle,$write);
fclose($handle);
}
//Pass in the search term, then the filename
deleteline('google','list.txt');
?>
thanks, oh grand PHP coder.
this will delete every line that has the word google in it, right?