I found this awesome snippet online. It shows a new testimonial at random on refresh of the page and am wondering how to show the array in an ascending order rather than random?
$target = sort(0, $num-1);
^ This was my attempt
<?php
/*
--------------------------------------------
Random Testimonial Generator Created by:
Ryan McCormick
Ntech Communications
Website: http://www.ntechcomm.com/
Blog: http://www.ntechcomm.com/blog/
Twitter: @ntechcomm
--------------------------------------------
*/
//Start Array
$testimonials = array();
$testimonials[0] = "Testimonial 1";
$testimonials[1] = "Testimonial 2";
$testimonials[2] = "Testimonial 3";
$testimonials[3] = "Testimonial 4";
//Automate script by counting all testimonials
$num = count($testimonials);
//randomize target testimonial
$target = rand(0, $num-1);
/*
To display testimonials on site
--------------------------------------------
place the following code in the
display area:
<?php echo $testimonials[$target]; ?>
--------------------------------------------
Use a PHP include to use this code on your
target page.
*/
?>
Output the testimonial in page with:
<?php echo $testimonials[$target]; ?>
To clarify:
The code i posted displays one testimonial randomly on refresh of the page. I would like it to keep this function and display only one at a time but I want them to display in the order they are added.