Appear Images

1

Hello, I have a PHP here that "generates" images recently hosted in the game I play in, and wanted to know if it is possible to make it generate more images without repeating any, is it possible? (it's important that you always continue the same value of images on the page, but just change the images)

 <?php
$url    = "http://hebbohotel.com.br/swf/gamedata/hebbo_texts.txt?9761831";
$data   = file_get_contents($url);

$newlines   = array("\n" ,"\r", "\r\n", ">", "<", "/");
$content    = str_replace($newlines, "", html_entity_decode($data));

$statusHtml = '/badge_desc_(.+?)=/';
preg_match_all($statusHtml, $content, $statusRaw);

$badges     = implode("-", $statusRaw[0]);
$badgeVar   = explode("=-badge_desc_", $badges);
$badgeVar2  = str_replace("=", "", $badgeVar);
$badgeVar3  = str_replace("badge_desc_", "", $badgeVar2);
$number     = count($badgeVar3);

$i = 1;
$e = 24;


while ($i <= $e)
{
    $number     = $number - 1;
    $imageUrl   = "http://hebbohotel.com.br/swf/c_images/album1584/" . $badgeVar3[$number] . ".gif";
echo '<div class="emblema" style="background:url(' . $imageUrl . ') no-repeat center,  #E7E7E7;"></div>'; // changed this echo to display the image.
    $i++;
}

?>

I want when I hit a button, it looks for the next images, hosted php link: link

    
asked by anonymous 05.06.2016 / 05:11

2 answers

0

In a quick glance at your code, your question might have two answers:

1 - I noticed that it was limited to 24 iterations:

$i = 1;
$e = 24;

while ($i <= $e)

If you leave the variable $ and dynamics of interactivity per click:

$i = 1;
$e = 24;
// aqui você entra com incremento de variável
$maisClique = ((isset($_GET['cliquei']) and !empty($_GET['cliquei']))?$_GET['cliquei']:false);

if(isset($maisClique) and !empty($maisClique)){
    $e += $maisClique;
}
while...

2 - If you want to replace the 24 images with new images of your server, then the index of the array is going to be changed:

// aqui você entra com incremento de variável
$maisClique = ((isset($_GET['cliquei']) and !empty($_GET['cliquei']))?$_GET['cliquei']:false);

// aqui você altera a porção dos elementos do array: 24, 48, 72, 96...
$number     = ((isset($maisClique) and !empty($maisClique))?($number - $maisClique):$number);

while ($i <= $e){
    $number = $number - 1;
    $imageUrl   = "http://hebbohotel.com.br/swf/c_images/album1584/" .$badgeVar3[$number] . ".gif";
    echo '<div class="emblema" style="background:url(' . $imageUrl . ') no-repeat center,  #E7E7E7;"></div>'; // changed this echo to display the image.
    $i++;
}

But this template asks you to run the page in each click, if you want to do it without reloading the page you need to increment an ajax, or jquery.

Note: ($ number - 1) refers to the decrement of the index of the matrix, if for the course of 24 iterations the index zero or empty is returned a null value for each image, the most common is to observe increment, ($ number + 1), in array index!

Note 2: $ number is the total of indices:

$number     = count($badgeVar3);

As you are, you have ordered the code to bring the last 24 elements in reverse order!

    
06.06.2016 / 02:05
0

Well, after seeing the page that I noticed there is still no button, then follow it:

    echo '<div class="emblema" style="background:url(' . $imageUrl . ') no-repeat center,  #E7E7E7;"></div>'; // changed this echo to display the image.
    $i++;
}
// aqui você define o valor $cliques que será calculado em $number para alterações da matriz
if(isset($_GET['cliquei']) and !empty($_GET['cliquei'])){
    $cliques = $_GET['cliquei'] + 24;
}else{
    $cliques = 24;
}
// aqui encerra o php e entra o botão cliquei
?>
<input type="button" onclick="window.location.replace('http://<?php echo $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?cliquei=".$cliques ?>')" value="cliquei" />

//--- fim

I believe this is the way for your array to update!

    
07.06.2016 / 04:24