Warptweet Posted October 9, 2007 Share Posted October 9, 2007 I've been creating a super modifyable version of my website for a while now. The navigation alone is quite complicated, and is modifyable completely. Now, for each and every page on my website there is a navigation, which will be added by using include("modules/navigation.php"); Here is the code for navigation.php: $navigation = file_get_contents("parts/navigation.txt"); $navigation2 = file_get_contents("parts/navigation2.txt"); $navigation3 = ""; while($navigation2 > 0){ $navigation3 .= " "; $navigation2 -= 1; } $navigation = explode(" | ", $navigation); $navigation4 = count($navigation); $navigation5 = ""; $first = 0; $second = 1; while($navigation4 > 2){ $navigation5 .= "<a href='$navigation[$first]'>$navigation[$second]</a>$navigation3"; $navigation4 -= 1; $first += 2; $second += 2; } implode(" | ", $navigation); echo substr($navigation5, 0, ($length-325)); Is it safe for me to execute this much code -- EACH page -- for the navigation ALONE? Can anyone tip me in a direction which can shorten this code? For more explanation of this code: It opens navigation.txt which contains 1 link on each line. It opens navigation2.txt which contains a number -- which the file takes, and eventually processes to a point where that number specified inside this file is the number of spaces between each link. (Example: If I change navigation2.txt to 15, there will be 15 spaces between each link. Each line in navigation.txt looks something like this: index.php | Home The part before the | indicates the link, the part after the | indicates the text of the link. In this case, it will show a link that displays the word "Home" and links to index.php. ---------------------- So, if anyone can help me to shorten this code, or assure me that this code is or is not fast to execute every page over and over again? remember, this is just the navigation alone, and the navigation is on EVERY page, so I need some professional advice. Also: Take a look here... www.warptweet.com/ultimate/navigation.php As you can see, at the END of all the links, there are a few spaces. In the code above you see me using a substring which forces me to shorten the end of all the links by 325 spaces!!! I have no idea why 325 spaces appear at the end of all the spaces, any help would obviously be appreciated, as it is nothing but more code to execute because of that flaw. Quote Link to comment https://forums.phpfreaks.com/topic/72414-does-this-slow-my-website-down/ Share on other sites More sharing options...
prime Posted October 9, 2007 Share Posted October 9, 2007 personally I use include for things like menu's and such. I cant see any huge problem myself, to be sure though, I say see what cooldude or one of the more experienced coders have to say first Quote Link to comment https://forums.phpfreaks.com/topic/72414-does-this-slow-my-website-down/#findComment-365193 Share on other sites More sharing options...
btherl Posted October 9, 2007 Share Posted October 9, 2007 I think it's fine. The amount of processing you do there is nothing compared to some sites I've seen If your navigation has hundreds or thousands of entries then you might need to do it another way. Quote Link to comment https://forums.phpfreaks.com/topic/72414-does-this-slow-my-website-down/#findComment-365200 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.