Locked Posted October 31, 2007 Share Posted October 31, 2007 Does anyone have any idea why this code is only replacing the last part? url:http://orella.co.uk/index4.php (Check the top left hand corner) <?php function Template($array,$replace){ $template="template.html"; if(file_exists($template)){ $template=implode("", file($template)); $num=0; while($array[$num]){ echo "Replacing: '$array[$num]' with '$replace[$num]'.<br>"; $page=preg_replace("/{".$array[$num]."}/",$replace[$num],$template); $num=$num+1; } return $page; }else{ die("Sorry! This theme no longer exists!"); } } $array=array("Title","Energy","NAV"); $replace=array("Page Title!","Energy level!","Nav!!"); echo Template($array,$replace); ?> Link to comment https://forums.phpfreaks.com/topic/75568-solved-preg_replacewhile/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.