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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:20:37+00:00 2026-06-18T01:20:37+00:00

This ASCII-art table is literally what I need to parse: \———\————-\————-\ | Username| IP

  • 0

This ASCII-art table is literally what I need to parse:

\---------\-------------\-------------\
| Username| IP          | Connected   |
\---------\-------------\-------------\
| test    | 127.0.0.1   | Yes         |
| atest   | 192.168.2.1 | No          |
| aaa     | 1.2.3.4     | Yes         |
\---------\-------------\-------------\

And I have to convert it into HTML like this

    <thead>
        <tr>
            <td>Username</td>
            <td>IP</td>
            <td>Connected</td>
        </tr>
    </thead>
    <tr>
        <td>Test</td>
        <td>127.0.0.1</td>
        <td>Yes</td>
    </tr>
    <tr>
        <td>Atest</td>
        <td>192.168.2.1</td>
        <td>No</td>
    </tr>
    <tr>
        <td>aaa</td>
        <td>1.2.3.4</td>
        <td>Yes</td>
    </tr>
</table>

Of course the content is only an example. The rows can be 40 like only 3.

Problem Solved

  • 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-18T01:20:38+00:00Added an answer on June 18, 2026 at 1:20 am

    Something like this should work. Example is a text file called my_data.txt which contains the following which is literally based on your example:

    \---------\-------------\-------------\
    | Username| IP          | Connected   |
    \---------\-------------\-------------\
    | test    | 127.0.0.1   | Yes         |
    | atest   | 192.168.2.1 | No          |
    | aaa     | 1.2.3.4     | Yes         |
    \---------\-------------\-------------\
    

    Here is the PHP script that reads the file into an array using file and then parses it into a <table>:

    <?php
    
    $data = file('my_data.txt');
    
    if (!empty($data)) {
        $value_array = array();
        // Strip out lines like this `\---------\-------------\-------------\`
        $data = preg_replace("/\\|-/", "", $data);
        $data = trim($data);
        if(!empty($data)) {
            echo '<table border="1">';
            foreach ($data as $key => $value) {
                if (!empty($value)) {
                    echo '<tr>';
                    $value_array = preg_split("/|/", $value);
                    foreach ($value_array as $table_cell_value) {
                        echo '<td>' . $table_cell_value . '</td>';
                    }
                    echo '</tr>';
                }
            }
            echo '</table>';
        }
    }
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I once did a programming test for a job, which involved producing ASCii art
Here is a table that I'm working with (an ascii art representation fo it):
There are some nice free image to ASCII art conversion sites like this one:
INFORMIX-SQL 4.1 - There's this ASCII UNIX file called passwd in /usr/informix/etc which holds
In short: For this code: Encoding.ASCII.GetBytes(‚) I want the output to be 130, but
What is wrong with this statement? return Encoding.ASCII.GetString(memoryStream.GetBuffer(), 0, memoryStream.Length) I know about the
I have an assignment on 8086 assembly (this is homework), I need to display
I would like to convert specific ascii file to csv. This ascii file has
I need a way to create a string of n chars. In this case
Lately I've seen several websites with large ASCII art headers in their HTML. I

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.