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

  • Home
  • SEARCH
  • 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 1093771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:52:26+00:00 2026-05-16T23:52:26+00:00

Need some php help in figuring out how use this array I created, but

  • 0

Need some php help in figuring out how use this array I created, but first of all I’m not sure if I done this right?? Its an array with names and href links that I would like to map for given server. Pls let me know if I constructed this properly:

  $server_array = array(
        'server1.domain' => array(
        'href' => 'https://server1.domain.com:8080'
  ),
        'server2.domain' => array(
        'href' => 'https://server2.domain.com:8080'
  ),
        'server3.domain' => array(
        'href' => 'https://server3.domain.com:9999'
 ...
);

I want to map the data from my key Server to one of these links. So far, I’ve created a table with the server names and all I want to do is map that server name to one of the above hyper links within the table.

Can someone show me how to tweak my print code to do this? Thanks.

Code to display the table with servername:

$keys = array('Server', Target','Set','Time', 'Length','Size','Status');
echo '<table id="stats_1"><tr>';
foreach ($keys as $column)
   echo '<th>' . $column . '</th>';
    echo '</tr>';

$counter=0;
foreach ($data as $row){
  $counter ++;
    $class = $counter % 2 === 0 ? 'alt1' : 'alt2';
    echo '<tr class="' . $class . '">';
     foreach ($keys as $column){
        if (isset($row[$column])){
          echo '<td>' . $row[$column] . '</td>';
        } elseif ($column == 'Status') {
          echo '<td> Check Logs </td>';
        } elseif ($column == 'Length') {
          echo '<td> n/a </td>';
        } elseif ($column == 'Size') {
          echo '<td> n/a </td>';
        } else {
          echo '<td> </td>';
        }
     }
}
echo '</table>';
  • 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-16T23:52:27+00:00Added an answer on May 16, 2026 at 11:52 pm

    If I got the question correctly, I would create the array like:

    $server_array = array(
            'server1.domain' => 'https://server1.domain.com:8080',
            'server2.domain' => 'https://server2.domain.com:8080',
            ...
    );
    

    And for creating the link you would have to do (assuming $row['Server'] would contain the name like 'server5.domain'):

    if ($column == 'Server'){
       echo '<td> <a href="' . $server_array[$row[$column]] . '">' . $row[$column] . '</a></td>';
    }
    

    Full code:

    $keys = array('Server', 'Target','Set','Time', 'Length','Size','Status');
    echo '<table id="stats_1"><tr>';
    foreach ($keys as $column) {
       echo '<th>' . $column . '</th>';
    }
    echo '</tr>';
    
    $counter=0;
    foreach ($data as $row){
      $counter ++;
      $class = $counter % 2 === 0 ? 'alt1' : 'alt2';
      echo '<tr class="' . $class . '">';
      foreach ($keys as $column){
         if (isset($row[$column])){
             if ($column == 'Server'){
                echo '<td> <a href="' . $server_array[$row[$column]] . '">' . $row[$column] . '</a></td>';
             } else {
                echo '<td>' . $row[$column] . '</td>';
             }
         } elseif ($column == 'Status') {
             echo '<td> Check Logs </td>';
         } elseif ($column == 'Length') {
             echo '<td> n/a </td>';
         } elseif ($column == 'Size') {
             echo '<td> n/a </td>';
         } else {
             echo '<td> </td>';
         }
      }
    }
    echo '</table>';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help figuring this out. I am trying to create a function
I need some help figuring out why the following scenario does not work. I'm
I need some help tweaking this php code to print out a default value
I need some help with a small php problem. But i dont know how
I'm currently working on my own PHP Framework, and I need some help figuring
i need some help with a php array, I need to remove the array
I need help figuring out some regular expressions. I'm running the dig command and
I haven't use PHP for some time, and I need some help to create
I need some help setting up a PHP array. I get a little lost
I need some help with sorting a multidimensional array in php. I need the

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.