Jump to content

Unusual Link Approach Good/Bad/Improvments?


tsilenzio

Recommended Posts

This works by using nested arrays..

 

Step One:

Fill an array with links. As for the key, give it the name u want the link to say

 

Step Two:

Take all the arrays and put them inside a single array. Yet again name the keys for each array the name u want to call the group

 

Note: Code and Preview below..

 

<?php

function output_array($array) {

    // Confusing eh? You should try writing it >.>
    // This will break down an array[should be a link array]
    // and output the nessesary parts
    foreach ($array as $key => $data) {
        if(!is_array($data)) {
            if($data == (basename($_SERVER["SCRIPT_NAME"]))) {
                // Uncomment line below to skip the current page from linking to itself
                //continue;
            }
            if(end($array) == $data) {
                echo("<tr><td nowrap=\"nowrap\" valign=\"center\" align=\"left\">"
                . "  <a href=\"$data\">$key</a></td></tr></table></p>");
            } else {
                echo("<tr><td nowrap=\"nowrap\" valign=\"center\" align=\"left\">"
                . "  <a href=\"$data\">$key</a></td></tr>");
            }
        } elseif(is_string($key)) {
            echo("<p><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>"
            . "<td nowrap=\"nowrap\" valign=\"center\" align=\"left\"><b>$key</b></td></tr>");
            output_array($data);
        } else {
            output_array($data);
        }
    }
}

$links = array(
    'Navigation' => array(
        'News' => 'news.php',
        'Login' => 'login.php',
        'Register' => 'register.php',
        'Lost Password' => 'lostpass.php',
        'Term of Service' => 'tos.php',
        'Contact Us' => 'contact.php',
        'About' => 'about.php'
    )
);

output_array($links);

?>

 

Output:

navuf3.png

Note: Your results WILL vary from my image, I have taken out a few parts since I took the image as you will see if you use the code.

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.