Can the foreach of smarty traverse oop Objects? What should I do?
Source: Internet
Author: User
Can the foreach of smarty traverse oop Objects? I know that {section} can traverse oop objects, but can I use foreach ?, Foreach is another solution for processing loops besides sections (select different solutions based on different needs). can foreach of foreac smarty traverse oop Objects?
I know that {section} can traverse oop objects, but can I use foreach?
------ Solution --------------------
Foreach is another solution for processing loops except section (different solutions are selected based on different needs ).
Foreach is used to process a simple array (the element types in the array are the same). Its format is much simpler than that of section. The disadvantage is that it can only process a simple array.
Foreach must be used in pairs with/foreach, and the from and item attributes must be specified.
The name attribute can be arbitrarily specified (a combination of letters, numbers, and underscores ).
Foreach can be nested, but it must be unique in the nested foreach name.
The from attribute (usually an array) determines the number of cycles.
The foreachelse statement is executed when the from variable has no value.
------ Solution --------------------
Of course.
For example
{Foreach from = $ arrMembersList item = objMemberInfo}
{$ ObjMemberInfo-> iBookId }:{$ objMemberInfo-> strMembersName}
{/Foreach}
------ Solution --------------------
Foreach from = $ array item = tt
$ Array [tt].
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.