Author Topic: Read & delete entries in txt file  (Read 52 times)

Sylvain

  • Guest
Read & delete entries in txt file
« on: January 27, 2012, 04:58:17 PM »
Hello, I'm requesting your help here cause I'm really confused.
I'm looking for deleting entries when an image doesn't load on my links test.

I got all my links in a .txt file like this :
links.txt =
Code: [Select]
<div class="gallery">
 <a href="http://www.website.com/page">
  <img src="http://tc16.easythumbhost.com/image.jpg" onerror="ImgError(this)"/>
 </a>
</div>
#enddiv

the "onerror" code in img src sends an "Image Missing" pic.
What I'd want is to change the "onerror" function to open a php script which deletes all the lines of the div.
This is the script I use to show the links on my page :
PHP Code: [Select]
 $links "links.txt";
 
$fd fopen ($links"r");
 
$content fread ($fd,filesize ($links));
 
fclose ($fd);
 
$delimiter "#enddiv";
 
$splitcontent explode($delimiter$content);
 
$output array_slice($splitcontent0,100);

 foreach ( 
$output as $divs )
{
 echo 
"$divs";
}


I've searched hours and tried lots of codes before posting
Help would be very appreciated. Thanks.