使用 short_open_tags 在 Foreach 循环内嵌套 Foreach 循环

Nesting Foreach loop inside Foreach loop using short_open_tags

我有以下 foreach 循环:

<?php
    $fields = CFS()->get('list-item-field');
?>
    <? foreach ($fields as $field) : ?>

        <?= $field['list-item-title'] ?>    

    <? endforeach ?>

我想在循环中添加另一个 foreach,如下所示:

<?php
    $fields = CFS()->get('item-field');
?>
    <? foreach ($fields as $field) : ?>

        <?= $field['list-item-title'] ?>

        <?php
            $values = CFS()->get('color');
        ?>
            <? foreach ($values as $value => $label) : ?>
                <? echo $value ; ?>
            <? endforeach ?>

    <? endforeach ?>

但是这不起作用,我收到错误消息:

Invalid Argument Supplied For Foreach()

好吧,我需要做一些实验,但我想通了,我怀疑这对很多人都有帮助,但不管我需要做什么:

<?php
    $fields = CFS()->get('item-field');
?>
    <? foreach ($fields as $field) : ?>

        <?= $field['list-item-title'] ?>

        <? foreach ($field['color'] as $colors => $label) :?>
            <? echo $colors ; ?>
        <? endforeach ?>

    <? endforeach ?>

这 post 帮助了:http://customfieldsuite.com/forums/questions/925/loop-within-a-loop