Re: Templating help

From: Date: Wed, 10 Jan 2001 10:42:44 +0000
Subject: Re: Templating help
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-33642@lists.php.net to get a copy of this message
> $template_file = "".$template_root."".$template_file.""; What are those empty strings supposed to do? This is the same thing: $template_file = $template_root.$template_file; > return implode("",(@file($template_file))); Ack! That's horrible. Do this instead: $fp = fopen($template_file) or die("Unable to open $template_file"); $file = fread($fp, filesize($template_file)); fclose($fp); return $file; > /* ****************************************************** > * $template_type decides weather Cool, make it snow. > if ( $template_type == '0' ) > $template_contents = > implode("",(@file($template_root.$template_file))); See above > > if ( is_array ( $template_data ) && is_array ( $template_replace > ) ) > { > > for ( $i=0; $i < count ( $template_replace ); $i++ ) > { > > $template_contents = > str_replace("{".$template_replace[$i]."}", $template_data[$i], > $template_contents); > > } Whoa.. foreach($template_replace as $key=>$val) { $template_contents = str_replace('{'.$val.'}',$template_data[$key], $template_contents); } -Rasmus

« previous php.general (#33642) next »