0

I have the following tpl codes:

{foreach from=$data.reviews item=item}
    {$item.user_name},{$item.datestamp}
{/foreach}

I'm creating a php file to simulate some data while designing this page. How should I code the array portion? Currently, I have the following:

$data = array('reviews' => array('user_name' => 'John',
                                 'datestamp' => '24 April 2012',
                                )
             );

However, very strangely the data displayed are JJ and 22. How can I display at least 2 info in the for loop?

1 Answer 1

2

Think you're missing a level. What you need is something like:

$Smarty->assign( 'data', array(
    'reviews' => array(
        array(
            'user_name' => 'testing',
            'datestamp' => 4534534
        ),
        array(
            'user_name' => 'testing2',
            'datestamp' => 45345343
        ),
    )
) );
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.