Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6200267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:20:08+00:00 2026-05-24T04:20:08+00:00

I use a PHP Switch statement to determine the pages of my website. So

  • 0

I use a PHP Switch statement to determine the pages of my website. So here is an example:

switch($page) {
    case "about":
        $title_name = "About Us";
        $page_content = "includes/about-us.php";
        include("inner.php");
    break;
    case "services":
        $title_name = "Services";
        $page_content = "includes/services.php";
        include("inner.php");
    break;
}

And my file structure is index.php?page=about which converts to /about/ using htaccess.

What I want to do is take all of my pages in that switch statement and automatically grab it and put it in a list so I can automatically have it write to my footer page where I will have all of the links.

So instead of manually typing in all of the links in the footer like: Home | About Us | Services | FAQ , it will pull it automatically based on the pages I provided in the Switch statement.

Is there a way to do this? It would also be good to automatically be able to add new pages and it will add a new case for the new page, and automatically create the page in the includes folder.

If anyone can point me in the right direction I would really appreciate it. From my understanding, I don’t believe you can do this with a switch statement, I would have to re-work the way I call the pages, right?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T04:20:10+00:00Added an answer on May 24, 2026 at 4:20 am

    Nope, it’s not possible using switch – but you could store those informations in an array:

    $page_list = array(
        'about' => array(
            'title' => 'About Us',
            'content' => 'includes/about-us.php',
        ),
        'services' => array(
            'title' => 'Services',
            'content' => 'includes/services.php',
        ),
    );
    
    if(isset($page_list[$page])) {
        $page_info = $page_list[$page];
    
        $title_name = $page_info['title'];
        $page_content = $page_info['content'];
    
        include("inner.php");
    } else {
        // 404 - file not found
    }
    
    // create links
    foreach($page_list as $link_name => $page_ent) {
        echo "<a href=\"/{$link_name}/\">{$page_ent['title']}</a><br />"
    }
    
    // output
    // <a href="/about/">About Us</a><br />
    // <a href="/services/">Services</a><br />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use a paging system like this: <?php $p = $_GET['p']; switch($p) { case
I can't use PHP in my HTML pages. For example, index.html . I've tried
I have this PHP case statement switch ($parts[count($parts) - 1]) { case 'restaurant_pos': include($_SERVER['DOCUMENT_ROOT']
I want to use PHP to replace javascript functions in HTML documents. For example:
The example below is an extráct from http://php.net/manual/de/control-structures.switch.php <?php $totaltime = 0; switch ($totaltime)
I use these files as base for my website: The menu.php : $p =
Use PHP and Mysql. Fields in my table (product) are id , full_price ,
I use php to display a table of data drawn from my mysql database.
I use php with ajax. <?php /* * Suppose, user has entered both correct
I am trying to use PHP to fire hits at Google to track newsletter

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.