Method for the smarty area loop in php _ PHP Tutorial

Source: Internet
Author: User
The smarty area loop method in php. The method of smarty region loop in php this article describes the method of smarty region loop in php. Share it with you for your reference. The specific implementation method is as follows: 1234567891011121 the smarty area loop method in php

This article describes how to cycle the smarty area in php. Share it with you for your reference. The specific implementation method is as follows:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

Smarty Test

{Foreach key = key1 item = item1 from = $ array1}

{/Foreach}

{$ Key1} {$ Item1}

1

2

3

4

5

6

7

Require 'libs/Smarty. class. php'; // contains the Smarty class library file

$ Smarty = new Smarty; // create a new Smarty object

$ Array1 = array (1 => "Simon", 2 => "Elaine", 3 => "Susan"); // define an array

$ Smarty-> assign ("array1", $ array1); // assign values to variables in the template

$ Smarty-> display('test3.htm'); // Display Page

?>

Another method:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

Smarty Test

{Section name = section1 loop = $ array1}

{/Section}

{$ Array1 [section1]}

1

2

3

4

5

6

7

Require 'libs/Smarty. class. php'; // contains the Smarty class library file

$ Smarty = new Smarty; // create a new Smarty object

$ Array1 = array (0 => "Simon", 1 => "Elaine", 2 => "Susan"); // define an array

$ Smarty-> assign ("array1", $ array1); // assign values to variables in the template

$ Smarty-> display('test10.htm'); // Display Page

?>

Examples in this article describes how to cycle the smarty area in php. Share it with you for your reference. The specific implementation method is as follows: 1 2 3 4 5 6 7 8 9 10 11 12 1...

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.