lundi 23 décembre 2019

php show data from an array in an order instead of random

I am showing data from an array in random using rand() . Is it possible to show the data in a systematic order instead of random ?

$one = data1;
$two = data2;
$three = data3;
$myarray = array($one, $two, $three)
$show = $myarray[rand(0,2)];

Note the $show variable is called dynamically in page & it outputs values of $myarray at many places on page

Ex. It outputs above array in random orders as data2,data1,data3,data3,data2,data1......

How do i code the above so that the result on page will be in a systematic order i.e. first to be shown will be the 1st value of array i.e. data1 then data2 then data3 then again data1 then data2 then data3 & so on...




Aucun commentaire:

Enregistrer un commentaire