3v4l.org

run code in 200+ PHP versions simultaneously
<section id="explore"> <div class="container-fluid"> <h2 class="white fs-h1">Explore</h2> <div class="compass"></div> </div> <!-- .container-fluid --> <?php # Random fields. $img_field = 3;//get_field('images'); $quotes_field = 5;//get_field('quotes'); # Long chain of destructuring to get random items from these: if($img_field && $quotes_field): $img_rand_keys = array_rand($img_field, 3); $quotes_rand_keys = array_rand($quotes_field, 3); $rand_imgs = [ $img_field[ $img_rand_keys[0] ]["image"], $img_field[ $img_rand_keys[1] ]["image"], $img_field[ $img_rand_keys[2] ]["image"], ]; $rand_quotes = [ $quotes_field[ $quotes_rand_keys[0] ]["quote"], $quotes_field[ $quotes_rand_keys[1] ]["quote"], $quotes_field[ $quotes_rand_keys[2] ]["quote"], ]; endif; # $img_field && $quotes_field ?> <div class="explore-grid container"> <?php # For the 6 items.. for($i=0;$i<6;$i++): if($i%2==0): // "Evens" ?> <div class="grid-item grid-item--quote col"> <div class="fontawesome five-stars"></div> <p>"<?php echo $rand_quotes[ floor(i/2) ] ?>"</p> </div> <? else: // "Odds" ?> <div class="grid-item grid-item--image col"> <img src="<?php echo $rand_imgs[ floor(i/2) ] ?>" /> </div> <? endif; // if..else endfor; // for($i=0..5) ?> </div> <!-- .explore-grid --> </section> <!-- #explore -->
Output for 7.3.0 - 7.3.1
<section id="explore"> <div class="container-fluid"> <h2 class="white fs-h1">Explore</h2> <div class="compass"></div> </div> <!-- .container-fluid --> Warning: array_rand() expects parameter 1 to be array, int given in /in/O9TR8 on line 13 Warning: array_rand() expects parameter 1 to be array, int given in /in/O9TR8 on line 14 <div class="explore-grid container"> <div class="grid-item grid-item--quote col"> <div class="fontawesome five-stars"></div> <p>" Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/O9TR8 on line 35 Warning: A non-numeric value encountered in /in/O9TR8 on line 35 "</p> </div> <div class="grid-item grid-item--image col"> <img src=" Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/O9TR8 on line 39 Warning: A non-numeric value encountered in /in/O9TR8 on line 39 " /> </div> <div class="grid-item grid-item--quote col"> <div class="fontawesome five-stars"></div> <p>" Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/O9TR8 on line 35 Warning: A non-numeric value encountered in /in/O9TR8 on line 35 "</p> </div> <div class="grid-item grid-item--image col"> <img src=" Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/O9TR8 on line 39 Warning: A non-numeric value encountered in /in/O9TR8 on line 39 " /> </div> <div class="grid-item grid-item--quote col"> <div class="fontawesome five-stars"></div> <p>" Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/O9TR8 on line 35 Warning: A non-numeric value encountered in /in/O9TR8 on line 35 "</p> </div> <div class="grid-item grid-item--image col"> <img src=" Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/O9TR8 on line 39 Warning: A non-numeric value encountered in /in/O9TR8 on line 39 " /> </div> </div> <!-- .explore-grid --> </section> <!-- #explore -->
Output for 7.2.0 - 7.2.13
<section id="explore"> <div class="container-fluid"> <h2 class="white fs-h1">Explore</h2> <div class="compass"></div> </div> <!-- .container-fluid --> Warning: array_rand() expects parameter 1 to be array, integer given in /in/O9TR8 on line 13 Warning: array_rand() expects parameter 1 to be array, integer given in /in/O9TR8 on line 14 <div class="explore-grid container"> <div class="grid-item grid-item--quote col"> <div class="fontawesome five-stars"></div> <p>" Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/O9TR8 on line 35 Warning: A non-numeric value encountered in /in/O9TR8 on line 35 "</p> </div> <div class="grid-item grid-item--image col"> <img src=" Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/O9TR8 on line 39 Warning: A non-numeric value encountered in /in/O9TR8 on line 39 " /> </div> <div class="grid-item grid-item--quote col"> <div class="fontawesome five-stars"></div> <p>" Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/O9TR8 on line 35 Warning: A non-numeric value encountered in /in/O9TR8 on line 35 "</p> </div> <div class="grid-item grid-item--image col"> <img src=" Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/O9TR8 on line 39 Warning: A non-numeric value encountered in /in/O9TR8 on line 39 " /> </div> <div class="grid-item grid-item--quote col"> <div class="fontawesome five-stars"></div> <p>" Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/O9TR8 on line 35 Warning: A non-numeric value encountered in /in/O9TR8 on line 35 "</p> </div> <div class="grid-item grid-item--image col"> <img src=" Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/O9TR8 on line 39 Warning: A non-numeric value encountered in /in/O9TR8 on line 39 " /> </div> </div> <!-- .explore-grid --> </section> <!-- #explore -->
Output for 7.1.25
<section id="explore"> <div class="container-fluid"> <h2 class="white fs-h1">Explore</h2> <div class="compass"></div> </div> <!-- .container-fluid --> Warning: array_rand() expects parameter 1 to be array, integer given in /in/O9TR8 on line 13 Warning: array_rand() expects parameter 1 to be array, integer given in /in/O9TR8 on line 14 <div class="explore-grid container"> <div class="grid-item grid-item--quote col"> <div class="fontawesome five-stars"></div> <p>" Notice: Use of undefined constant i - assumed 'i' in /in/O9TR8 on line 35 Warning: A non-numeric value encountered in /in/O9TR8 on line 35 "</p> </div> <div class="grid-item grid-item--image col"> <img src=" Notice: Use of undefined constant i - assumed 'i' in /in/O9TR8 on line 39 Warning: A non-numeric value encountered in /in/O9TR8 on line 39 " /> </div> <div class="grid-item grid-item--quote col"> <div class="fontawesome five-stars"></div> <p>" Notice: Use of undefined constant i - assumed 'i' in /in/O9TR8 on line 35 Warning: A non-numeric value encountered in /in/O9TR8 on line 35 "</p> </div> <div class="grid-item grid-item--image col"> <img src=" Notice: Use of undefined constant i - assumed 'i' in /in/O9TR8 on line 39 Warning: A non-numeric value encountered in /in/O9TR8 on line 39 " /> </div> <div class="grid-item grid-item--quote col"> <div class="fontawesome five-stars"></div> <p>" Notice: Use of undefined constant i - assumed 'i' in /in/O9TR8 on line 35 Warning: A non-numeric value encountered in /in/O9TR8 on line 35 "</p> </div> <div class="grid-item grid-item--image col"> <img src=" Notice: Use of undefined constant i - assumed 'i' in /in/O9TR8 on line 39 Warning: A non-numeric value encountered in /in/O9TR8 on line 39 " /> </div> </div> <!-- .explore-grid --> </section> <!-- #explore -->