All pastes #582105 Raw Edit

Mine

public text v1 · immutable
·published 2007-06-21 21:00 UTC
rendered paste body
	function parse($code, $vals) {
		$results = array();
		preg_match_all("/\{(\w+)\}/i", $code, $results, PREG_SET_ORDER);
		for ($i=0; $i<count($results); $i++ )
			$code = str_replace($results[$i][0], $vals[$results[$i][1]], $code);
		return $code;
	}

	while($html = mysql_fetch_assoc($result)) {
		$row = mysql_fetch_assoc(mysql_query("SELECT * FROM `edit_newsletter` where `action` = '$action'"));
		$values = array(
			"DRAGON_CONTENT" => parse($row['page_code'], array(
					"NEWS_LIST" => $newsList, 
					"NEWS_CONTENT" => $newsContent, 
					"NEWS_TITLE" => $newsTitle, 
					"NEWS_DATE" => $newsDate,
					"NEWS_EDIT_LIST" => $newsEditList)),
			"PAGE_TITLE" => $row['page_title'] 
						);
		echo parse($html['template_code'], $values);
	}