Jump to content

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;

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.