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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:45:27+00:00 2026-05-23T11:45:27+00:00

Please help me on this. $str = col_1 col_2 col_3 row1 row2 row3 row12

  • 0

Please help me on this.

$str = "col_1          col_2  col_3
row1 row2 row3
row12 row22        row33";

$arr = explode("\n", $str);

foreach($arr as $line)
{
   $temp_arr = explode(WHAT HERE, $line); 
}

How do I explode each line into array??
I want $temp_arr[0] = col_1, $temp_arr[1] = col2, $temp_arr[2] = col_3
next line will have $temp_arr[0] = row1, $temp_arr[1] = row2

You guys are awesome. It works on my example but it doesn’t work on my real problem. I export windows xp processes and want to explode them.

Caption              CommandLine                                                                                                                                                                                                                                                                   ProcessId  
System Idle Process                                                                                                                                                                                                                                                                                0          
System                                                                                                                                                                                                                                                                                             4          
smss.exe             \SystemRoot\System32\smss.exe                                                                                                                                                                                                                                                 604        
avgrsx.exe           C:\PROGRA~1\AVG\AVG10\avgrsx.exe /restart /boot                                                                                                                                                                                                                               692        
csrss.exe            C:\WINDOWS\system32\csrss.exe ObjectDirectory=\Windows SharedSection=1024,3072,512 Windows=On SubSystemType=Windows ServerDll=basesrv,1 ServerDll=winsrv:UserServerDllInitialization,3 ServerDll=winsrv:ConServerDllInitialization,2 ProfileControl=Off MaxRequestThreads=16  780        
winlogon.exe         winlogon.exe                                                                                                                                                                                                                                                                  820        
services.exe         C:\WINDOWS\system32\services.exe                                                                                                                                                                                                                                              880        
lsass.exe            C:\WINDOWS\system32\lsass.exe                                                                                                                                                                                                                                                 892        
nvsvc32.exe          C:\WINDOWS\system32\nvsvc32.exe                                                                                                                                                                                                                                               1052       
svchost.exe          C:\WINDOWS\system32\svchost -k DcomLaunch                                                                                                                                                                                                                                     1168       
svchost.exe          C:\WINDOWS\system32\svchost -k rpcss                                                                                                                                                                                                                                          1240       
svchost.exe          C:\WINDOWS\System32\svchost.exe -k netsvcs                                                                                                                                                                                                                                    1328       
svchost.exe          C:\WINDOWS\system32\svchost.exe -k NetworkService                                                                                                                                                                                                                             1404       
svchost.exe          C:\WINDOWS\system32\svchost.exe -k LocalService                                                                                                                                                                                                                               1520       
spoolsv.exe          C:\WINDOWS\system32\spoolsv.exe                                                                                                                                                                                                                                               1664       
explorer.exe         C:\WINDOWS\Explorer.EXE                                                                                                                                                                                                                                                       1956       
jqs.exe              "C:\Program Files\Java\jre6\bin\jqs.exe" -service -config "C:\Program Files\Java\jre6\lib\deploy\jqs\jqs.conf"                                                                                                                                                                460        
avgtray.exe          "C:\Program Files\AVG\AVG10\avgtray.exe"                                                                                                                                                                                                                                      1156       
rundll32.exe         "C:\WINDOWS\system32\RUNDLL32.EXE" C:\WINDOWS\system32\NvMcTray.dll,NvTaskbarInit                                                                                                                                                                                             1204       
alg.exe              C:\WINDOWS\System32\alg.exe                                                                                                                                                                                                                                                   1376       
AVGIDSMonitor.exe    "C:\Program Files\AVG\AVG10\Identity Protection\agent\bin\avgidsmonitor.exe"                                                                                                                                                                                                  660        
iexplore.exe         "C:\Program Files\Internet Explorer\iexplore.exe"                                                                                                                                                                                                                             620        
OUTLOOK.EXE          "C:\Program Files\Microsoft Office\Office12\OUTLOOK.EXE"  /recycle                                                                                                                                                                                                            1884       
SQLyog.exe           "C:\Program Files\SQLyog\SQLyog.exe"                                                                                                                                                                                                                                          2596       
UniKeyNT.exe         "C:\Program Files\unikey40RC2-1101-win32\UniKeyNT.exe"                                                                                                                                                                                                                        964        
avgcsrvx.exe         C:\Program Files\AVG\AVG10\avgcsrvx.exe /pipeName=4f758821-d931-4842-ae08-b81fe89b843a /coreSdkOptions=0 /binaryPath="C:\Program Files\AVG\AVG10\" /registryPath="SYSTEM\CurrentControlSet\Services\Avg\Avg10"                                                                3788       
svchost.exe          C:\WINDOWS\system32\svchost.exe -k imgsvc                                                                                                                                                                                                                                     3604       
mstsc.exe            "C:\WINDOWS\system32\mstsc.exe"                                                                                                                                                                                                                                               3868       
notepad++.exe        "C:\Program Files\Notepad++\notepad++.exe"                                                                                                                                                                                                                                    4072       
notepad.exe          "C:\WINDOWS\system32\NOTEPAD.EXE" C:\Documents and Settings\Quy Nguyen\Desktop\cool.txt                                                                                                                                                                                       2228       
cmd.exe              "C:\WINDOWS\system32\cmd.exe"                                                                                                                                                                                                                                                 2552       
wmic.exe             WMIC /OUTPUT:C:\ProcessList.txt PROCESS get Caption,Commandline,Processid                                                                                                                                                                                                     2480       
wmiprvse.exe         C:\WINDOWS\system32\wbem\wmiprvse.exe                                                                                                                                                                                                                                         1744       
  • 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-23T11:45:28+00:00Added an answer on May 23, 2026 at 11:45 am

    replace

    $temp_arr = explode(WHAT HERE, $line);
    

    with

    $temp_arr = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY);
    

    Edit: added PREG_SPLIT_NO_EMPTY

    OK, so your question changed a bit. This code should do exactly what you want:

    $processes = 'the list you posted';
    
    $temp = preg_split('/\s*(?:\r?\n)+/', $processes, -1, PREG_SPLIT_NO_EMPTY);
    $process_list = array();
    foreach ($temp as $process) {
        $process_list[] = array_pad( // array_pad makes the length consistent
            preg_split(
                '/\s{2,}/', // match only 2 or more consecutive spaces for splitting
                $process,
                3,
                PREG_SPLIT_NO_EMPTY), // ignore empty matches (i.e., end of line)
            3, // pad array to a length of 3
            ''
        );
    }
    
    $process_list_final = array();
    $process_list_titles = array_shift($process_list);
    
    foreach ($process_list as &$plist_item) {
        $plist_item = array_combine($process_list_titles, $plist_item);
    }
    

    It probably needs a bit of cleanup, but you can do that on your own =)

    Some functions for you to look up:

    • preg_split
    • array_pad
    • array_shift
    • array_combine
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please help me out on this explode() function issue. I am getting unexpected results
Please help this would be my last problem in dealing with access database with
Please help me convert this line to C#. objManagementBaseObject.SetPropertyValue(hDefKey, CType(&H & Hex(RegistryHive.LocalMachine), Long)) Related
Please help me about this issue... In my application i have calender where user
can you please help me with this issue the String class does not have
Can anybody please help me with this as I have no idea why public
Hi Guys could you please help me refactor this so that it is sensibly
Hi Guys can you please help me with this error? What is it? Server
I am new in CSS so please help me in this problem. I hope
Please help! I have been grappling with this error for days and I cannot

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.