Jump to content

Integrating HTML like phpBB forums.


Ellingsen

Recommended Posts

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.

<?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;

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.