Well that part is just going to look up a database. I'd rather it put all 3 values in an array so I can easily look up the info in the db.
{text, 2, 3}
$array = Array("text", "2", "3");
nothing fancy
Main Topics
Browse All TopicsI am creating a template engine and I would like the tokens laid out like this {var, 1, 1}... How do I parse anything within { } that has 3 values within? Please let me know!
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Whoops... sorry about that...
Here you go:
<?php
function parseVar($s) {
preg_match_all('/\{(.*?),(
array_shift($matches);
return $matches;
}
$s = 'laid out like this {var, 1, 1}... How {var2, 3, 2}';
// collect al tokens in a big array $a
$a = parseVar($s);
// count the matches
$count = count($a[0]);
// for loop to process all matches
for ($i = 0; $i < $count; $i++) {
// assign vars per match
$name = $a[0][$i];
$val1 = $a[1][$i];
$val2 = $a[2][$i];
// remove this print statement, just an example of how to use it
print ("Name: $name <br>Value1: $val1 <br>Value2: $val2 <br><br>");
// here you have $name, $val1, $val2 to work with.
// use them here to lookup stuff in the DB
// The for loop will continue to process all the found tokens.
}
?>
Business Accounts
Answer for Membership
by: TeRReFPosted on 2006-08-26 at 11:33:52ID: 17396813
How do you want it parsed?