Jump to content

Does this slow my website down?


Warptweet

Recommended Posts

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.