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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:06:25+00:00 2026-05-23T01:06:25+00:00

I have been working on this a while. I see multi-dimensional arrays in php

  • 0

I have been working on this a while. I see multi-dimensional arrays in php are not that easy.
Here is my code:

      while (list($key,$value) = each ($x))
        {
        Print "$key  => $value\n<br>\n";
        }

This works well to display the keys of the main array. what I get is :

visitors => Array 
actions => Array 
actions-average => Array 
time-average => Array 
pages-entrance => Array

What I want is the visitors and the value (number of visitors), value of actions, etc.
I want to then save the value in Mysql. Some I will have to convert from a string to and int or date.

I need to list one more level deep. But I cannot see how to do this.
————–Added ———–
So what I have is an array of arrays. I need to step through each array.

  • 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-23T01:06:25+00:00Added an answer on May 23, 2026 at 1:06 am

    did you try print_r ?

    if you need more control over formatting then embedded loops as suggested by @Nick is the best option. Although it would be more natural and safer to use foreach loops rather than while.

    foreach($x as $key => $value){
      foreach( $value as $key2 => $value2){
        print "$key $key2 => $value2\n<br />\n";
      }
    }
    

    see PHP manual: each , there is a “caution” frame.

    EDIT 1
    I update sample code above for 2 day array.

    It seems your array has more than 2 dimension. Then you should use recursion.

    function my_print_r($x,$header="")
    {
      foreach($x as $key => $value){
        if(is_array($value))
          my_print_r($value,$header . $key .  " " );
        else
          print "$header $key2 => $value2\n<br />\n";
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on some legacy C++ code that uses variable length structures
I have been working on this for the greater part of the day and
I have been working on Flex for last couple of months and as this
I have this classic ASP site which has been working fine until we updated
I have been working with a string[] array in C# that gets returned from
I'm not a Notes programmer, however, for my sins, have been working on some
I've been working on this for a while now and I can't seem to
I have been working with entity framework and ASP MVC for a while. I
I've been working on this for a while now and I cant seem to
I have been working on a huge project for work for a while now,

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.