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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:09:09+00:00 2026-06-04T02:09:09+00:00

I have data that’s setup the following way: array( 0 => array( ‘data_id’ =>

  • 0

I have data that’s setup the following way:

array(
      0 => array(
                  'data_id' => 0,
                  'elem_value' => 'phone',
                  'elem_prettyname' => 'Phone Number'
                 ),
      1 => array(
                  'data_id' => 0,
                  'elem_value' => 'email',
                  'elem_prettyname' => 'Email Address'
                 ),
      2 => array(
                  'data_id' => 1,
                  'elem_value' => 'phone',
                  'elem_prettyname' => 'Phone Number'
                 ),
      3 => array(
                  'data_id' => 1,
                  'elem_value' => 'email',
                  'elem_prettyname' => 'Email Address'
                 )
     )
)

I’m trying to turn that into a csv file that looks like:

"Data ID","Phone Number","Email Address"
0,"phone","email"
1,"phone","email"

But I can’t figure it out for the life of me. I have tons of random arrays and they go nowhere.

I should mention that the elem_prettyname can have an infinite number of elements.. IE not just Phone Number and Email Address.

Can anyone point me in the right direction to get that formatted correctly?

Thanks in advance.

  • 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-04T02:09:12+00:00Added an answer on June 4, 2026 at 2:09 am

    you need to convert your data to an array that looks like this: 0,"phone","email" first.

    Something like this:

    $lines = array();
    foreach($inTheQuestion as $row) {
        if (empty($lines[$row['data_id']])) {
            $lines[$row['data_id']] = array($row['data_id']);
        }
        $lines[$row['data_id']][] = $row['elem_value'];
    }
    var_dump($lines);
    

    If that’s the format you want (which isn’t clear from the question) – you then simply dump the data into a file with fputcsv or, simply, with fwrite.

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

Sidebar

Related Questions

I have data that is in an array, these are the ID's for users
I have data that comes out of a DB in a normalized way with
I have data that looks like the following: ID | Location | Attendees |
I have data that has been stored using binary serialization for the following class:
I have data that is of the following form: 'of' 45001 23366 21859591 52876216
I have data that is organized in kind of a key-key format, rather than
I have data that looks like this: #info #info2 1:SRX004541 Submitter: UT-MGS, UT-MGS Study:
I have data that I would like to compute some statistics with. The data
For an XML file I am creating I have data that contains a bullet
I have some data that won't printf.... echo works, but not printf There is

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.