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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:02:18+00:00 2026-05-18T04:02:18+00:00

I have an array inside an array and I’d like to simply print out

  • 0

I have an array inside an array and I’d like to simply print out the contents of it… the problem is what I’m trying doesn’t work… ie

        foreach($retval as $k=>$v){

          if (is_array($v)){

            foreach($v as $l=>$w){

            echo $l . ' = ' . $w . '<br />';

            }

        } else {

          echo $k . ' = ' . $v . '<br />';

        }

Doing that however I end up with:

id = 2

name = Speakers

form_field = hidden

display_order = 0

groups = Array

So I’m not getting a foreach in that inside array.. what am I doing wrong? It seems actually that my code believes everything return is an array when I’m pretty sure that only ‘groups’ is an array.


the structure of the array looks like so:

array ( 0 => array ( 'id' => 2, 'name' => 'Speakers', 'form_field' => 'hidden', 'display_order' => '0', 'groups' => array ( 0 => array ( 'bit' => '1', 'name' => 'don', 'display_order' => '4', 'subscribers' => 8, ), 1 => array ( 'bit' => '2', 'name' => 'tyler', 'display_order' => '5', 'subscribers' => 0, ), 2 => array ( 'bit' => '4', 'name' => 'stephen', 'display_order' => '6', 'subscribers' => 0, ), 3 => array ( 'bit' => '8', 'name' => 'daniel', 'display_order' => '7', 'subscribers' => 0, ), 4 => array ( 'bit' => '16', 'name' => 'william', 'display_order' => '8', 'subscribers' => 0, ), 5 => array ( 'bit' => '32', 'name' => 'bobbys', 'display_order' => '9', 'subscribers' => 0, ), ), ), )

Long story short, I’m actually just trying to search this whole thing for say the name ‘bobby’ and get a simple true or false on whether that value exists anywhere in there.

  • 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-18T04:02:19+00:00Added an answer on May 18, 2026 at 4:02 am

    You’re assuming that arrays are only doubly-nested, when $retval[<something>]['groups'] is also an array. Use recursion to handle this instead of just adding levels upon levels.

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

Sidebar

Related Questions

i want to have a foreach loop where the initial array is changed inside
I have a array inside my PHP app that looks like this: Array (
I have a couple UIViewControllers that I am trying to access an array inside
I'd like to have an array inside of a bit-packed struct. I statically know
I have an array that looks like the one below. I'm trying to group
I am trying to get an array inside a NSMutableDictionary that looks like this:
I have an array set inside a velocity template that contains some paths. The
I have a struct with a dynamic array inside of it: struct mystruct {
I have a question in initializing my structure array inside a structure array. for
I have a Matlab function that creates a cell array with matrixes inside. It

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.