Jump to content

showing blocks of elements using for loop


dennismonsewicz

Recommended Posts

I am trying to create a script that will show a block of images for every nine items in an array. So it doesn't need to show the block of images for every 9 items, but every time the counter hits 9 show a block of images.

 

Make sense?

 

I am stumped as all get out. Thanks for all the help in advance!

Really simple

<?php
// array containg 100 elements
$x = range(1,100);

$counter = 1;
foreach($x as $item) {
print $counter."<br />";
if($counter == 9) {
	// display images
	print "displaying images<br />";
	$counter = 1;
}
else {
	$counter++;	
}
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.