0
각 항목에 대해 슬라이드 쇼를 만들고 싶습니다.Foreach 루프의 PHP 배열이 다릅니 까?
첫 번째 코드와 만 작동하며 다른 코드는 작동하지 않습니다.
내가 뭘 잘못하고 있는지 아는 사람이 있습니까? ??
내 코드 :
<?php
// check $items variable exists and is not empty
if(isset($items) && !empty($items)) :
// init item count
$count = 1;
?>
<div class="shelf">
<?php foreach($items as $key=>$item): ?>
<?php
// calculate if this item is the last on the shelf
// if item number can be divided by 5 with no remainders
$last_item = ((($count) % 5 == 0)? 'item-last' : '');
?>
<div class="item <?php echo $last_item; ?>">
<a href="/items/view/<?php echo $item['Item']['slug']; ?>">
<p><?php echo $item['Item']['name'] ?></p>
<div id="CustomSlideshow">
<?php
if ($item['Item']['vidsite'] = 'Pornhub') {
for($i=1;$i<=16;$i++) {
$array[] = str_replace('.jpg',sprintf("%01d",$i).'.jpg',$item['Item']['vidimgdir']);
} ?>
<img src="<?php echo($array[0]); ?>"/>
<img src="<?php echo($array[1]); ?>"/>
<img src="<?php echo($array[2]); ?>"/>
<img src="<?php echo($array[3]); ?>"/>
<img src="<?php echo($array[4]); ?>"/>
<img src="<?php echo($array[5]); ?>"/>
<img src="<?php echo($array[6]); ?>"/>
<img src="<?php echo($array[7]); ?>"/>
<img src="<?php echo($array[8]); ?>"/>
<img src="<?php echo($array[9]); ?>"/>
<img src="<?php echo($array[10]); ?>"/>
<img src="<?php echo($array[11]); ?>"/>
<img src="<?php echo($array[12]); ?>"/>
<img src="<?php echo($array[13]); ?>"/>
<img src="<?php echo($array[14]); ?>"/>
<img src="<?php echo($array[15]); ?>"/>
<?php
$array=array();
} ?>
</div>
</a>
</div>
<?php
// if this is the last item, close the shelf div and create a new one
if(!empty($last_item)) {
echo '<div class="clear"></div>';
echo '</div>';
echo '<div class="shelf">';
}
?>
<?php $count++; ?>
<?php endforeach; ?>
고마워요, 지금 작동 중입니다 .. – grosseskino