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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:16:05+00:00 2026-05-31T19:16:05+00:00

I am trying to use my logger to dump variables to my logfile. I

  • 0

I am trying to use my logger to dump variables to my logfile.
I need it to write down arrays within arrays.
Could you explain please how to do this ? (I am not sure of how to pass the sub-array of the rest of the array but here’s what I came up with, which obviously is missing something)

Thanks

function logRec($param)
{
    if(!isset($param))
        return;

    foreach($param as $key=>$value)
    {
        if(is_array($value))
        {
            echo "<b>nested array</b><br />";
            logRec(next($param));
        }
        else
        {   
            echo $param;
            return;
        }   
    }    
}   

$par = array("ABC","DEF",array("Apple","Peach","Melon",array("Cube","Sphere","Pyramid")));
logRec($par);
  • 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-31T19:16:06+00:00Added an answer on May 31, 2026 at 7:16 pm

    I would just do this:

    write_to_log_or_whatever(print_r($par, true));
    

    The second parameter on print_r() sets it to return the output, rather than sending it to the buffer as usual.

    If seeing it on too many lines isn’t good for your log file, the other thing you can do is json_encode() it, but then you have to decide if having JSON-encoded data in your log is helpful. If you are going through your logs manually, it can be. But, if you have log file analysis tools, it often is a pain.

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

Sidebar

Related Questions

I am need paint my image. I'm trying use JQuery in here this link:
I'm trying to use Spring to inject a SLF4J logger into a class like
I'm trying to use this tutorial to make plots with Gnuplot in C++. However
I'm trying to use a Singleton Class (its a program-wide debug logger called 'PrisLog')
So Im trying to use webstart on this application of mine and I keep
I'm trying to use log4j my log4j.propreties: log4j.rootLogger=DEBUG, out log4j.logger.org.springframework=INFO log4j.logger.org.apache.activemq=INFO log4j.logger.org.apache.activemq.spring=WARN log4j.logger.org.apache.servicemix=DEBUG, stdout
I'm trying to use a logger across a web application. I have added the
I'm trying to use MongoDB to store my sessions, and I need to get
I'm trying to find a little bug and need the logger inside one of
I am trying to use the combination Django custom logger and Celery task to

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.