PHP Coding Tips

Showing posts with label contents. Show all posts
Showing posts with label contents. Show all posts

Tuesday, August 7, 2012

print_r in smarty - How to print your array contents in smarty template.

You can print a array contents like in php print_r() function in smarty tempalte. The common mistake is to forget about second print_r parametr for returning it's output. This parameter have to be set to true. If you forget to set it to true, your array contents propably will be somewhere at begining of a content. This is the solution:
{$myArray|@print_r:true}
Notice the @ symbol that provides parsing argument as array, not as string.