0

i want to use array and fetch that with rainTpl, i can assign array for it but i cant fetch

PHP:

$portalTopics   =array(
array('id' => 4,
        'subject' => 1111111,
        'description' => vvvvvvvvvvvvv,
        'date_time' => '2013-05-26',
        'posted_by' => 1,
        'tags' => '',
        'category' => 1,
        't_status' => 1,
        'post_type' => 1,
        'can_comment' => 1,
        'from_dateTime' =>' 0000-00-00 00:00:00',
        'to_dateTime' => '0000-00-00 00:00:00',
        'portal' => 0,
        'thumb_image' => 'eNortjKwUlKyBlwwB0UBlw',
        'order_display' => 9
      ),
array('id' => 5,
        'subject' => 22222222222,
        'description' => fffffffffffff,
        'date_time' => '2013-05-26',
        'posted_by' => 1,
        'tags' => '',
        'category' => 1,
        't_status' => 1,
        'post_type' => 1,
        'can_comment' => 1,
        'from_dateTime' =>' 0000-00-00 00:00:00',
        'to_dateTime' => '0000-00-00 00:00:00',
        'portal' => 0,
        'thumb_image' => 'eNortjKwUlKyBlwwB0UBlw',
        'order_display' => 9
      )          
);

    $tpl->assign( $portalSettings );
    $tpl->assign( 'portalTopics',$portalTopics );
    echo $tpl->draw( 'main');

this below code is my main.html file for fetch portalTopics array

RainTPL:

<div> 
    <ul>
        {loop="portalTopics"}
            <li>{$key} = {$value}</li>
        {/loop}
    </ul>
</div>

RESULT :

0 = Array
1 = Array
4

1 回答 1

1

您有一个二维数组,但您只循环外部数组。如果要显示第二级的键值对,则必须在循环(嵌套循环)中放置另一个循环,以访问内部数组中的键值对。

<div> 
    <ul>
        {loop="portalTopics"}
            {loop="value"}
                <li>{$key} = {$value}</li>
            {/loop}
        {/loop}
    </ul>
</div>
于 2013-06-11T15:20:33.303 回答