0

What i need this to do is delete what is inside the div eliment already before it writes the the div again. If anyone can help me i give my thanks, :)

<?php

$file = "./test.html";
$imgs = glob("1/*.*");


$dom = new DOMDocument();
$dom->loadHTMLFile($file);
$container = $dom->getElementByID("container");
if(count($imgs) == 0 || $imgs === false)
    die('Error: glob is failing.');

foreach($imgs as $img)
{
    $basename = pathinfo($img, PATHINFO_BASENAME);
    $tag = $dom->createElement("img");
    $tag->setAttribute('src', '1/'.$basename);
    $container->appendChild($tag);

    $tag = null;
}

$dom->saveHTMLFile($file);

?>
2
Contributors
2
Replies
25
Views
2 Years
Discussion Span
Last Post by michael.sullivan.1422
0

What i need this to do is delete what is inside the div eliment already before it writes the the div again.

What is the before and after situation?

0

the code will rewrite the file names every time the page loads causing repeated file names. If i use php to delete what is inside the div then the code above will write the file names and they will only be on the line once. as it is when the code above runs everytime you refresh it builds the same thing over and over

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.