phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


Smarty Variable: Associative Arrays

Tag: smarty, template, array, associative array, variable   Category: PHP Classes
post: 02 May 2008 read: 1,118


Smarty Variable Step by Step Tutorial - Part 1: Following sample using associative array at smarty:

Create a file named "test.php" enter following code:


<?php
require 'Smarty/libs/Smarty.class.php';

$smarty = new Smarty;

$smarty->assign('title','Contact Detail');
$smarty->assign('contact',array('id'=>1,
                                'name'=>'Wiwit',
								'email'=>'wsiswoutomo at yahoo dot com',
								'phone'=>'123456789'
                                ));
$smarty->display('test.tpl');
?>

Next, build template by create a file named "test.tpl" within template. Enter following code


<html>
  <head>
    <title>{$title}</title>
  </head>
  <body>
    id : {$contact.id} <br>
    name : {$contact.name} <br>    
    email : {$contact.email} <br>    
    phone : {$contact.phone} <br>    
  </body>
</html>



| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
PHP WDDX: Recordset Element
Joomla: Fast Road to Understand Component Programming
Web Services: How PHP Kiss VB.NET? (Part 1)
mod_rewrite - Part 1: create your "fantasy" URL
PHP Supported Metacharacters (You Must Know Them)

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


624
posting