Please help with the code below.
I am a beginner and only recently began to learn programming.
List of variables and their values:
$slideMenu = ''; $slides = array( array( 'background' => 'image', 'h2' => 'Text', 'text' => 'Text' ), array( 'background' => 'image', 'h2' => 'Text', 'text' => 'Text' ), array( 'background' => 'image', 'h2' => 'Text', 'text' => 'Text' ), ); And further, here:
<?php foreach ($slides as $i => $slide) { ?> <div id="slide-<?php echo $i + 1; ?>" data-id="<?php echo $i + 1; ?>" class="slide" style="display: <?php echo($i > 0 ? 'none' : 'block'); ?>;background-image: url(<?php echo $slide['background'] ?>);"> <div class="container"> <div style="width: 40%;color: #fff;" class="col"> <div style="padding: 0 15px;"> <h2><?php echo $slide['h2'] ?></h2> <p><?php echo $slide['text'] ?></p> </div> </div> </div> </div> <?php $slideMenu .= '<a href="#" data-slide-id="' . ($i + 1) . '" data-rel="#slide-' . ($i + 1) . '" class="' . ($i == 0 ? 'current' : '') . '"></a>'; ?> <?php } ?> These parts are not completely clear:
<div id="slide-<?php echo $i + 1; ?>" data-id="<?php echo $i + 1; ?>" class="slide" style="display: <?php echo($i > 0 ? 'none' : 'block'); ?>;background-image: url(<?php echo $slide['background'] ?>);"> <?php $slideMenu .= '<a href="#" data-slide-id="' . ($i + 1) . '" data-rel="#slide-' . ($i + 1) . '" class="' . ($i == 0 ? 'current' : '') . '"></a>'; ?>