can you make make php code more versatile?

jhuu01

New member
currently i've been studying php for 2days. im working on something that can create 3 rows and 3 column that shuffle images. i want to make it moe versatile meaning if i add one more array, one more row will be also added and shuffle will still work. i know this easy for you guys but im still learning. here's my code:

<?php
$images = array('1.jpg','2.jpg','3.jpg','4.jpg','5.jpg','6.jpg','7.jpg','8.jpg','9.jpg');
shuffle($images);

for($x=0; $x<3; $x++)
{
echo '<tr>';
for($y=$x*3; $y<(($x+1)*3) ; $y++)
{
echo '<td align="center"><img src="';
echo $images[$y];
echo '" width="150" height="150"></td>';
}
echo'</tr>';
}
?>
 
Back
Top