View Single Post
Old 12-21-2007, 04:49 PM   #1 (permalink)
Tanax
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default preg_match and that stuff..

Hey!

I don't know barely anything about this, and I want to create a simple template system where I would replace variables.

What I would want is like this:

HTML Code:
Hello and welcome {user.username}!
Your last visit was {user.lastvisit} here on {site.name}!
The "username" is the key in the "user" array.
So
HTML Code:
{user.lastvisit}
would fetch
PHP Code:
$user['lastvisit'
PHP Code:
$user = array();
$user['lastvisit'] = 'something';
$user['username'] = 'Tanax';

$site = array();
$site['name'] = 'TalkPHP';

$values = array();
$values[] = $user;
$values[] = $site;

$tpl->parse('index'$values); 
How would the function parse look like??
Tanax is offline  
Reply With Quote