#native_company# #native_desc#
#native_cta#

Customized HTML tags – BBS Style

By silrayn silverwolf
on November 15, 2003

Version: 1.0

Type: Function

Category: HTML

License: GNU Library Public License

Description: this is a small, easy to understand function for use of newbies. Modelled on blog design tags. It replaces custom tags like [TAG] with content in a user-defined associative array. Full instructions are with the code.

<?php

/* *************************************************************************************

LICENSE/TERMS OF USE:
	- No money, no support, no need to pay.  
	- Provided as is with no warranties or guarantees whatsoever.
	
*************************************************************************************


Function Name:  createHtml

Description: the function does it like some blogs do using custom tags to place some data into an html page.

Inputs: 
$html_file = the html file where the tags are
$homemade_tags = homemade tags to replace
$tag_values = the values to replace the tags

Output:
print out the html with replaced values 

*************************************************************************************

How to use this function:

1. The homemade tags have to be tags with square brackets. 
	e.g. [WHATEVER_NAME_TAG]
	
2. $homemade_tags variable should be an array of homemade tags without the square brackets
	e.g. WHATEVER_NAME_TAG

3. $tag_values variable should be an array of associative values with homemade tags without brackets as keys.  This where you put the values you want to replace the homemade tags with.
	e.g. $tag_values['WHATEVER_NAME_TAG'] 

4. Put it as the last function to execute in any script because: 
	4.1 The variables have to exist for it to print
	4.2 It ends the program by printing the html page.  Nothing can follow after it.
	

************************************************************************************* */

function createHtml($html_file, $homemade_tags, $tag_values){
	
	$filename = $html_file;
	$fd = fopen ($filename, "r");
	$contents = fread ($fd, filesize ($filename));
	fclose ($fd);
	
	foreach($homemade_tags as $tag){
		$tag_pattern = ''[' . $tag . ']'';
		$contents = preg_replace($tag_pattern, $tag_values[$tag], $contents);
	}

	die($contents);
}

?>