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 8215537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:49:25+00:00 2026-06-07T11:49:25+00:00

I want to insert data from included file and create HTML-elements automatically. In data.php

  • 0

I want to insert data from included file and create HTML-elements automatically.

In data.php I have:

$vps_de_dc1_s1 = array(
"name"=>"Germany, DC1, First",
"price"=>"10€",
);

$vps_de_dc1_s2 = array(
"name"=>"Germany, DC1, Second",
"price"=>"10€",
);

$vps_de_dc2_s1 …, $vps_de_dc2_s2 …, $vps_cz_dc1_s1 …, $vps_cz_dc12_s1 …, etc.

And in page.php there should be:

include('data.php');

<tr class="vps_de_dc1">
    <td class="column-left">
        name
    </td>
    <td class="column-right">
        $vps_de_dc1_s1["name"]
    </td>
    <td class="column-right">
        $vps_de_dc1_s2["name"]
    </td>
    <td class="column-right">
        $vps_de_dc1_s3["name"]
    </td>
</tr>

<tr class="vps_de_dc2">
    <td class="column-left">
        name
    </td>
    <td class="column-right">
        $vps_de_dc2_s1["name"]
    </td>
    <td class="column-right">
        $vps_de_dc2_s2["name"]
    </td>
    <td class="column-right">
        $vps_de_dc2_s3["name"]
    </td>
</tr>

...

I want to know, is it possible to automate somehow creation of table elements here?


Update: In fact, for echo I have to manually create all table instances. But I want to find a way to create all these <tr class="vps_*_dc*">...</tr> automatically for every $vps_* from data.php.

  • 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-06-07T11:49:27+00:00Added an answer on June 7, 2026 at 11:49 am

    First start with data.php. At the bottom, add a master array of all your arrays:

    $masterArray = array(
        'vps_de' => array ('dc' => 2, 's' => 4), // The key is the root name.
        'vps_cz' => array ('dc' => 2, 's' => 4), // The value is information about how many dc and s exist per location.
        // This example means that this has 2 dc and 4 s for a total of 8 possible arrays that you've defined.
        ...
    );
    

    In page.php:

    foreach ($masterArray as $varName => $infoArray) // Iterating through the master list.
    {
        for ($dc = 1; $dc <= $infoArray['dc']; $dc++) // Iterating through however many numbers up to the dc limit.
        {
            $className = $varName . '_dc' . $dc; // Creating the class name, which is the location key root concatenated with the dc number.
            echo '<tr class="' . $className . '">'; // Echo the table row.
            for ($s = 1; $s <= $infoArray['s']; $s++) // Iterating through however many numbers up to the s limit.
            {
                $arrayName = $className . '_s' . $s; // Creating the name of the variable, reference to the array.
                if (isset($$arrayName)) // Checking to see if the variable by the name we just created exists.
                {
                    $tmpArray = $$arrayName; // Using a variable variable to reference the array using its name.
                    echo '<td class="column-left">';
                    echo $tmpArray['name']; // I think you can use $$arrayName['name'] here, but it's been loaded to $tmpArray just to be safe.
                    echo '</td>';
                }
            }
            echo '</tr>';
        }
    }
    

    Edit: After reading through your question some more, it appears that your requirements are more complex than I first thought.

    Hopefully this is what you’re looking for.

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some data enclosed in HTML tags. I want to insert this data
I'm new to Java. I want to create Java Array and insert data into
I want to create a service which will insert provided data into spreadsheet fields
I want insert a custom snippet into an XML file from code within an
I read from file store the data into a list; I want to add
I want to save data to xml file , which include Create xml file
I want to insert data from wavemaker into database which will be inserted by
I want to load data from a MySQL database to a PHP page using
I want to insert data into a table where I don't know the next
I want to insert data into the postgresql database of OpenERP, I am able

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.