我有几行ACF中继器。
我需要检查所有$distance
值是否都超过100。
<?php if( have_rows('store') ): ?>
<?php while( have_rows('store') ): the_row();
$distance = get_sub_field('distance'); ?>
<?php echo $distance; ?>
<?php endwhile; ?>
<?php endif; ?>
我通过制作一个数组来解决此问题,然后使用min
进行检查。
<?php if( have_rows('store') ): $distances = array(); ?>
<?php while( have_rows('store') ): the_row();
$distance = get_sub_field('distance'); ?>
$distances[] = $distance;
<?php if (min($distances) >= 100) { echo 'all over 100'; } ?>
<?php endwhile; ?>
<?php endif; ?>