Last active
November 28, 2016 11:50
-
-
Save ZerglingGo/c2999f5dae796ccb3a17358f951b9406 to your computer and use it in GitHub Desktop.
Output different images for each page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$defaultPage = 'main'; | |
$page = isset($_GET['page']) ? $_GET['page'] : $defaultPage; // /page/{$page} | |
$imageCount = [ | |
'main' => 5, | |
'click_prot' => 6, | |
'request' => 1, | |
'news_ad' => 1, | |
'info' => 1, | |
]; | |
if(array_key_exists($page, $imageCount) === false) { | |
$page = $defaultPage; | |
} | |
for($i = 1; $i <= $imageCount[$page]; $i++) { | |
echo "<img src='/img/pages/{$page}/".str_pad($i, 2, "0", STR_PAD_LEFT).".jpg' />\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment