Smarty loop, control loop solution using comparison operators-php Tutorial

Source: Internet
Author: User
The Smarty loop uses the comparison operator to control the loop. The smarty loop array is also used, but a loop is implemented by the comparison operator to control the loop. Example: PHPcodefor ($ i0; $ I & lt; 100; $ I ++) {echo $ I;} is used to control the number of loops with $ I & lt; 100, but how does smarty implement the loop body instead of an array? ------ Solve the cycle of Smarty and control the loop using comparison operators
The smarty loop array is also used, but a comparison operator is required to control the loop.
Example:

PHP code
  For ($ I = 0; $ I <100; $ I ++) {echo $ I ;}

It is to use $ I <100 to control the number of cycles, and how to implement smarty when the subject of the loop is not an array?

------ Solution --------------------
HTML code
  
  
    {For $ foo = 1 to 5} {if $ foo lt 3}
  • {$ Foo}
  • {/If} {/}
// Output
  • 1
  • 2

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.