Knowledge - Transfers
Smarty Variable: Associative Arrays
ollowing sample using associative array at smarty:
Create a file named “test.php” enter following code:
01 | <?php |
02 | require 'Smarty/libs/Smarty.class.php' ; |
03 |
04 | $smarty = new Smarty; |
05 |
06 | $smarty ->assign( 'title' , 'Contact Detail' ); |
07 | $smarty ->assign( 'contact' , array ( 'id' =>1, |
08 | 'name' => 'Wiwit' , |
09 | 'email' => 'wsiswoutomo at yahoo dot com' , |
10 | 'phone' => '123456789' |
11 | )); |
12 | $smarty ->display( 'test.tpl' ); |
13 | ?> |
Next, build template by create a file named “test.tpl” within template. Enter following code
01 | <html> |
02 | <head> |
03 | <title>{ $title }</title> |
04 | </head> |
05 | <body> |
06 | id : { $contact .id} <br> |
07 | name : { $contact .name} <br> |
08 | email : { $contact .email} <br> |
09 | phone : { $contact .phone} <br> |
10 | </body> |
11 | </html> Courtesy : http://www.phpeveryday.com/articles/Smarty-Variable-Associative-Arrays-P611.html |
Categories
- Accounts, Finance
- Architect,Interior Design
- Automobiles
- Banking, Financial Services
- BPO, KPO
- Construction, Engineering
- Consultants
- Content, Journalism
- Engineering Design
- Export, Import
- Fashion
- Feng Shui
- Gadgets
- Global, Climate
- Healthcare, Medical
- Hotels, Restaurants
- HR, Admin
- Insurance
- IT, Software Services
- IT- Hardware
- Management
- Marketing, Advertising
- Media, Entertainment
- NGO
- Other
- Pharma, Biotech
- Photography
- Recipe
- Retail
- Site Engineering
- Teaching, Education
- Telecom
- Travel
- Trekking and Mountaineering
- TV, Films
- Web, Graphic Design
Calendar
February 2012 M T W T F S S « Jul 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
Add Widgets (Secondary Sidebar)
This is your Secondary Sidebar. Edit this content that appears here in the widgets panel by adding or removing widgets in the Secondary Sidebar area.




