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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:06:45+00:00 2026-05-16T07:06:45+00:00

Can someone pls show me how to map this correctly? I am trying to

  • 0

Can someone pls show me how to map this correctly? I am trying to understand how to use php explode() and organizing the values in a way that I can retrieve and print them in some organized matter. For each record I want to put a name=value in a particular bucket. I have (7) max buckets per record. Sometimes I have records that won’t fill each bucket.

(for example record (2) is missing attributes (5,6,7) and record (3) is missing attribute (4)).

1-Column=host1.colo.sub;2-Column=Fri Aug 13;3-Column=db9.nfl.colo2.;4-Column=00:00:03;5-Column=01:55:02;6-Column=87.24 MB;7-Column=Success;
1-Column=host1.colo.sub;2-Column=Fri Aug 13;3-Column=pdb2.colo2.;4-Column=04:00:02;
1-Column=host1.colo.sub;2-Column=Fri Aug 13;3-Column=gl3_lvm;5-Column=04:48:06;6-Column=54.64 MB;7-Column=Success;

So far I wrote this to view my output:

<?php
$InputFile = file("test.txt");
foreach ($InputFile as $line){
    $pieces = explode(";", $line);
         //print $pieces[0];
         //print $pieces[1];
         //print $pieces[2];
         print $pieces[3];
         //print $pieces[4];
         //print $pieces[5];
         //print $pieces[6];
//print_r($line);
}
?>

I would like to print out similar values for each attribute instead of this where its mixed.
Using ‘print $pieces[3];’

4-Column=00:00:034-Column=04:00:025-Column=04:48:06
  • 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-16T07:06:46+00:00Added an answer on May 16, 2026 at 7:06 am
    $InputFile = file("test.txt");
    foreach ($InputFile as $line){
      preg_match('~(1-Column[^;]*;?)?(2-Column[^;]*)?;?(3-Column[^;]*)?;?(4-Column[^;]*)?;?(5-Column[^;]*)?;?(6-Column[^;]*)?;?(7-Column[^;]*)?;?~',$line,$pieces);
      $pieces = array_pad($pieces,8,'');
      echo "<pre>";print_r($pieces);echo "</pre>";
    
    }
    

    output:

    Array
    (
        [0] => 1-Column=host1.colo.sub;2-Column=Fri Aug 13;3-Column=db9.nfl.colo2.;4-Column=00:00:03;5-Column=01:55:02;6-Column=87.24 MB;7-Column=Success;
        [1] => 1-Column=host1.colo.sub;
        [2] => 2-Column=Fri Aug 13
        [3] => 3-Column=db9.nfl.colo2.
        [4] => 4-Column=00:00:03
        [5] => 5-Column=01:55:02
        [6] => 6-Column=87.24 MB
        [7] => 7-Column=Success
    )
    
    Array
    (
        [0] => 1-Column=host1.colo.sub;2-Column=Fri Aug 13;3-Column=pdb2.colo2.;4-Column=04:00:02;
        [1] => 1-Column=host1.colo.sub;
        [2] => 2-Column=Fri Aug 13
        [3] => 3-Column=pdb2.colo2.
        [4] => 4-Column=04:00:02
        [5] => 
        [6] => 
        [7] => 
    )
    
    Array
    (
        [0] => 1-Column=host1.colo.sub;2-Column=Fri Aug 13;3-Column=gl3_lvm;5-Column=04:48:06;6-Column=54.64 MB;7-Column=Success;
        [1] => 1-Column=host1.colo.sub;
        [2] => 2-Column=Fri Aug 13
        [3] => 3-Column=gl3_lvm
        [4] => 
        [5] => 5-Column=04:48:06
        [6] => 6-Column=54.64 MB
        [7] => 7-Column=Success
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

can someone tell me what seems to be the issue with this <?php $increment
can someone help me pls, im new to vb.net and im trying to work
Can someone please explain to me why I keep getting this PLS-00905 error for
Can someone please tell me what this means: 07-04 09:54:38.048: I/DetailActivity(15496): Title that is
Can someone please explain how Read/Show works.. I cannot find any tutorials on it.
Can someone tell me how to modify this regex to allow periods in a
Can someone please explain to me how this responsive approach works? This was done
can someone take a look at this please http://jsfiddle.net/bloodygeese/ecscY/56/ it looks like I have
can someone pls tell me how can i execute my HelloWorld.java in apache hadoop
Can someone help me pls. I am ready to deploy my web application. 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.