phpeveryday.com

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


Smarty Variable: Array Index

Tag: smarty, template, array, array index, variable   Category: PHP Classes
post: 02 May 2008 read: 236


Smarty Variable Step by Step Tutorial - Part 2: Following sample using array indexed 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(1,'Wiwit','wsiswoutomo at yahoo dot com','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[0]} <br>
    name : {$contact[1]} <br>    
    email : {$contact[2]} <br>    
    phone : {$contact[3]} <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:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

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


615
posting