Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Automate HTML Preview JPGs for Clients
<?php
//While <= number of files to create
$count = 1;
while($count <= 18) {
if($count === 1) {
$filename = 'index.html';
}
else {
$filename = $count.'.html';
}
if($count === 18){
$linkto = 'index.html';
}
else {
$linkto = $count+1 . '.html';
}
$img = 'img/'.$count.'.jpg';
$html = <<<EOD
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<title>Paulo</title>
<style type="text/css">
img {
margin:0 auto;
max-width:100%;
height:auto;
display:block
}
</style>
</head>
<body>
<a href="$linkto"><img src="$img" alt=""></a>
</body>
</html>
EOD;
$fh = fopen($filename, 'w');
fwrite($fh, $html);
fclose($fh);
echo "File ".$count.".html created.";
echo "<br><br>";
$count++;
}
echo "Robot done, unplug me.";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.