mme Posted December 2, 2008 Share Posted December 2, 2008 Hi why doesn't this code work ? Its supposed to include the the relevant page with the .html extension except when it is the testimonials page then its a .php extension <? $pages = array("home","about","where","how","testimonials","contact","site_map"); $go=$pages[0] . ".html"; for ($i=0;$i<count($pages);$i++) { if (strtolower($_GET['page'])==$pages[$i]) { if ($pages[$i]="testimonials") {$go=$pages[$i] . ".php";} else { $go=$pages[$i] . ".html";} break; } } include($go); ?> Link to comment https://forums.phpfreaks.com/topic/135238-solved-page-include/ Share on other sites More sharing options...
flyhoney Posted December 2, 2008 Share Posted December 2, 2008 Use the == operator for comparisons: <?php $pages = array( "home", "about", "where", "how", "testimonials", "contact", "site_map" ); $go = $pages[0] . ".html"; for ($i = 0; $i < count($pages); $i++) { if (strtolower($_GET['page']) == $pages[$i]) { if ($pages[$i] == "testimonials") { $go = $pages[$i] . ".php"; } else { $go = $pages[$i] . ".html"; } break; } } include($go); ?> Link to comment https://forums.phpfreaks.com/topic/135238-solved-page-include/#findComment-704411 Share on other sites More sharing options...
mme Posted December 2, 2008 Author Share Posted December 2, 2008 Thanks so much All working now Link to comment https://forums.phpfreaks.com/topic/135238-solved-page-include/#findComment-704436 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.