问题是:数组值在每列上显示双倍 需要解决以下问题:数组值应显示从数组接收的每列唯一行,如果不是,则显示 Nan。 这是我的代码
$('.owl-carousel').owlCarousel({
loop:true,
margin:10,
autoplay:true,
nav:true,
responsive:{
0:{
items:1
},
600:{
items:3
},
1000:{
items:3
}
}
})
height: 10rem;
background: #009688;
display: flex;
justify-content: center;
align-items: center;
font-size: 70px;
color: #fff;
margin: 10px;
border-radius: 10px;
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.min.css">
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.4.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js"></script>
<?php $arr = array(0=>1,1=>2,2=>3);
print_r($arr);
?>
<div class="owl-carousel owl-theme">
<?php for ($i = 0; $i <count($arr) ; $i++) {?>
<div class="item">
<h4><?php echo $i ?></h4>
<h4><?php echo $i ?></h4>
</div>
<?php } ?>
</div>
我也尝试过嵌套循环,例如 `
<div class="item">
<?php for ($j = 0; $j <$i ; $j++) {?>
<h4><?php echo $i ?></h4>
<h4><?php echo $i ?></h4>
<?php } ?>
但是没有用, 需要一个解决方案来在每列的行上显示从数组接收到的每个值并且应该只有两行如果没有记录或任何列的行无法访问值,那么该列的行应该显示 Nan。