hi, i'm working on a template system. Basically i'm building raw
contents in arrays and then put them in templates by some special
tags.
for loop systems my basic array structure is like this:
$array['key'][]['keyword'] = ...
for example, for a bulletin board system, array structure for
categories is something like this:
$array['categories'][]['text_category_name'] = ...
it is looped through database recordset, so final array for 2 categories can be:
$array['categories'][0]['text_category_name'] = 'programming'
$array['categories'][1]['text_category_name'] = 'life'
template file structure for loops is something like this (ex, categories):
[$text_category_name$]
i can easily loop this template and replace [$text_category_name] for
every category set in the array. after removing the comment tags i get
the final content:
programming
life
But i'm stuck with nested loops. For example i want to put related
forums after each categories.
array structure is:
$array['categories'][0]['text_category_name'] = programming
$array['categories'][0]['forums'][0]['text_forum_name'] = php
$array['categories'][0]['forums'][1]['text_forum_name'] = ruby
$array['categories'][1]['text_category_name'] = life
$array['categories'][1]['forums'][0]['text_forum_name'] = music
$array['categories'][1]['forums'][1]['text_forum_name'] = sports
template structure is:
[$text_category_name$]
[$text_forum_name$]
i've written some functions, used them recursively but it didn't work.
actually i couldn't find the true logic. note that it isn't a limited
array. it can have messages under each forums, peoples under each
messages, so on..
help me find the true approach to handle this. thank you.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php