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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:25:06+00:00 2026-06-01T19:25:06+00:00

Would appreciate any help with this.:) I have the following text file: roomA Springer,

  • 0

Would appreciate any help with this.:)

I have the following text file:

roomA     Springer, Jerry    js@email.com
roomB     Cruise, Tom        tc@email.com
roomC     Jovi, Bon          bj@email.com

and I want to sort it by the surname so it outputs:

Cruise, Tom      roomB        tc@email.com
Jovi, Bon        roomC        bj@email.com
Springer, Jerry  roomA        js@email.com

I know how to load the file:

$a = file("details.txt");

and think I have to use explode() to split up the data (tab-seperated):

$array = explode("\t", $a);

this makes the name the second element in the array.

How do I put the string back together with the name coming first, followed by the room and email?
Thanks.

  • 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-01T19:25:08+00:00Added an answer on June 1, 2026 at 7:25 pm

    Do a var_dump($array) and it will display you the indexes. You then only need to swap two elements with each other. Here is a trick:

    list($array[0], $array[1]) = array($array[1], $array[0]);
    

    After that, you can implode the result as you did explode it:

    $line = implode("\t", $array);
    

    Hope this is helpful. Ah well, and for sorting, take a look at array_multisort.

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

Sidebar

Related Questions

I'm relatively new to Java and would appreciate any help on this! I have
Any help here would be greatly appreciated. I have this table hospital Nurse |
I would appreciate any help on this issue. Lets say I want to load
Any help with this problem would be fantastic. I appreciate all contributions! Let us
I would really appreciate any help with the following problem: I need to be
Would very much appreciate any help or hint on were to go next. I'm
I would really appreciate any jquery expert help as a method I've used previously,
I'm very new to C++ and would really appreciate any and all help. I
I'm very new to programming and I would really appreciate any help! I am
I have the following in a text file: ('bob', '10') ('Ben', '10') ('Ben', '9')

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.