put image in a PHP array [closed]

0

I have an event counter on my game site, where I wanted to appear a git before the event name.

I need some help where I would follow this order.

zombie:


layout.php

<divclass="Themebox Eventos-Box" style="background-image:url(<?PHP echo $layout_name; ?>/images/themeboxes/eventos.png);">
    <img style="position:relative;top: 30px;left: 5px;" width="170" src="<?php echo $layout_name; ?>/images/themeboxes/bg_events.png">
    <div class="eventos" align=" ">
        <div class="evento-font" align="center">Proximo:</div>
        <div id="cdEventos" style="margin-top: 40px; font-size: 14px;" align="center">Carregando...</div>
    </div>
</div>

Function you have in layout.php

function getEventos() {
            $.ajax({
                type: "POST", url: "eventos.php", data: "action=do",
                complete: function(data){
                    var data = data.responseText;
                    $("#cdEventos").html(data);

                }
            })
        };

Events.php

<?php 
date_default_timezone_set('America/Sao_Paulo');

$horaAtual = new DateTime();

$horarios = array(
    '1' => array('nome' => 'Zombie', 'hora' => '10:00:00', 'img' => '/images/eventos/zombie.gif'),
    '2' => array('nome' => 'Zombie', 'hora' => '13:00:00', 'img' => '/images/eventos/zombie.gif'),
    '3' => array('nome' => 'Zombie', 'hora' => '18:00:00', 'img' => '/images/eventos/zombie.gif'),

    '4' => array('nome' => 'Rush War', 'hora' => '12:00:00'),
    '5' => array('nome' => 'Rush War', 'hora' => '15:00:00'),
    '6' => array('nome' => 'Rush War', 'hora' => '21:00:00'),

    '7' => array('nome' => 'Defend The Base', 'hora' => '09:00:00'),
    '8' => array('nome' => 'Defend The Base', 'hora' => '17:00:00'),
    '9' => array('nome' => 'Defend The Base', 'hora' => '23:00:00'),

    '10' => array('nome' => 'Castle War', 'hora' => '20:00:00'),

    '11' => array('nome' => 'Capture The Flag', 'hora' => '11:00:00'),
    '12' => array('nome' => 'Capture The Flag', 'hora' => '14:00:00'),
    '13' => array('nome' => 'Capture The Flag', 'hora' => '19:00:00'),

    '14' => array('nome' => 'Good Time', 'hora' => '08:00:00', 'img' => '/images/eventos/good.png'),
    '15' => array('nome' => 'Good Time', 'hora' => '15:00:00', 'img' => '/images/eventos/good.png'),
    '16' => array('nome' => 'Good Time', 'hora' => '21:00:00', 'img' => '/images/eventos/good.png')


    );

foreach ($horarios as  $value) {
    $horaEventos = new DateTime($value['hora']);

    if ($horaAtual<$horaEventos) {
        $diff = $horaAtual->diff($horaEventos);

        echo $value['nome']. ": " ['img']. "<center/>". $diff->format('%H:%I:%S');
        break;
    }   
}

?>
    
asked by anonymous 06.09.2017 / 21:28

1 answer

1

I have solved it!


foreach($horariosas$value){$horaEventos=newDateTime($value['hora']);if($horaAtual<$horaEventos){$diff=$horaAtual->diff($horaEventos);echo$value['img']."<center/><br/>";
        echo $value['nome']. ": <center/>". $diff->format('%H:%I:%S');
        break;
    }   
}
    
06.09.2017 / 21:46