Ellingsen Posted April 12, 2008 Share Posted April 12, 2008 Hi. Im trying to figure out how the phpBB intregrate their HTML example: <a href="{U_SEARCH_UNANSWERED}">{L_SEARCH_UNANSWERED}</a> in a HTML file that is included, the values are ofen stored in a array, anyone know a tutorial for this? thx Quote Link to comment https://forums.phpfreaks.com/topic/100790-integrating-html-like-phpbb-forums/ Share on other sites More sharing options...
Daniel0 Posted April 13, 2008 Share Posted April 13, 2008 I'm going to guess that the ones prefixed with U_ are URLs and L_ are language strings. You can do that rather easily with str_replace(). <?php $urls = array( 'SEARCH_UNANSWERED' => 'index.php?whatever=something', 'SOMETHING_ELSE' => 'index.php?foo=bar', ); $language_en = array( 'SEARCH_UNANSWERED' => 'Unanswered', 'SOMETHING_ELSE' => 'Something Else', ); // we suppose we have the data containing the template in a variable called $data foreach ($urls as $key => $url) { $data = str_replace("{U_{$key}}", $url, $data); } foreach ($language_en as $key => $string) { $data = str_replace("{L_{$key}}", $string, $data); } ?> I'll also move this to the PHP Help forum. Quote Link to comment https://forums.phpfreaks.com/topic/100790-integrating-html-like-phpbb-forums/#findComment-515937 Share on other sites More sharing options...
Ellingsen Posted April 13, 2008 Author Share Posted April 13, 2008 Well, thats not the part i need help for. I have some problems expressing myself in english I woulder how they can use a .html file and input php variables trough {VARIABEL} without any <? echo $variabel; ?>. Quote Link to comment https://forums.phpfreaks.com/topic/100790-integrating-html-like-phpbb-forums/#findComment-515991 Share on other sites More sharing options...
Daniel0 Posted April 13, 2008 Share Posted April 13, 2008 Probably because they're replacing them with something else as shown above. Quote Link to comment https://forums.phpfreaks.com/topic/100790-integrating-html-like-phpbb-forums/#findComment-516008 Share on other sites More sharing options...
ignace Posted April 13, 2008 Share Posted April 13, 2008 <?php $content = file_get_contents('template.html'); // html file with {VARIABLES} defined $replacement_parts = array(); while (false != (list($key, $value) = each($replacement_parts))) { $content = str_replace('{' . $key . '}', $value, $content); } echo $content; Quote Link to comment https://forums.phpfreaks.com/topic/100790-integrating-html-like-phpbb-forums/#findComment-516013 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.