誰かが私を助けてくれることを願っています、
私のウェブサイトにはたくさんの画像があります、それはこれに似ています、
$usp = array('/images/usp1.jpg',
'/images/usp2.jpg',
'/images/usp3.jpg',
'/images/usp4.jpg',
'/images/usp5.jpg',
'/images/usp6.jpg'
);
商品をループして商品の画像と詳細をに表示するページがありますli
。私がやりたいことは、配列からのランダムな選択でループを開始し、$usp
次に4つの製品を表示し、次に配列から別のランダムな選択を$usp
配置し、次に別の4つの製品を表示し、次に配列から別のランダムな選択を表示し$usp
ます。
本質的に私はこの効果が欲しい
USP PRODUCT PRODUCT
PRODUCT PRODUCT USP
PRODUCT PRODUCT PRODUCT
PRODUCT USP PRODUCT
PRODUCT PRODUCT PRODUCT
USP PRODUCT PRODUCT
現在、これは私が持っているループです。
<?php if(count($product_sets) >= 1) : ?>
<div class="clear clearfix productWrap" id="homeBestSellers">
<!-- <h3 class="label"><?php echo $category_details->categoryTitle; ?> <br> Product Sets</h3> -->
<ul class="clear clearfix productBoxes">
<?php
$number_of_blanks = (3 - (count($product_sets) % 3)); // 0, 1 or 2.
if ($number_of_blanks == 3) :
$number_of_blanks = 0;
endif;
$number_of_rows = ceil(count($product_sets) / 3);
$currentItem = 1;
foreach ($product_sets as $product)
{
$currentRow = ceil($currentItem / 3);
$currentColumn = $currentItem - (($currentRow - 1) * 3);
if ($number_of_blanks == 2) :
if (($number_of_rows > 1 && $currentRow == ($number_of_rows - 1) && $currentColumn == 2) || ($number_of_rows == 1 && $currentColumn == 1)) :
?>
<li><img src="<?php echo site_url('assets/img/blocks/guarantee.png'); ?>" alt="5 Year Guarantee" width="242" height="156"></li>
<?php
$currentItem++;
endif;
endif;
?>
<li class="<?php if($currentItem % 3 == 0) echo 'endHomeBlock';?>">
<?php $this->load->view('blocks/product_small', array('product' => $product)); ?>
</li>
<?php
$currentItem++;
}
if ($number_of_blanks > 0) :
?>
<li><img src="<?php echo site_url('assets/img/blocks/phone-number.png'); ?>" alt="Phone Number" width="242" height="156"></li>
<?php
endif;
?>
</ul><!-- #productSets -->
</div><!-- #productWrap -->
<?php endif; ?>
希望する効果が得られるようにこれを変更するにはどうすればよいですか?