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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:38:48+00:00 2026-05-13T13:38:48+00:00

I have the following array from DB. Now I want to get shin in

  • 0

I have the following array from DB.

Now I want to get shin in [user] => shin.

How can I get it with PHP?

Number in [29] => Array could be any number.

Thanks in advance.

Array
(
    [29] => Array
        (
            [0] => stdClass Object
                (
                    [day] => 29
                    [eventContent] => school ski tada
                    [eventTitle] => school ski
                    [id] => 24
                    [user] => shin
                    [user_id] => 1
                )

            [1] => stdClass Object
                (
                    [day] => 29
                    [eventContent] => north again
                    [eventTitle] => ski hello
                    [id] => 26
                    [user] => shin
                    [user_id] => 1
                )

        )

    [31] => Array
        (
            [0] => stdClass Object
                (
                    [day] => 31
                    [eventContent] => test
                    [eventTitle] => test
                    [id] => 21
                    [user] => shin
                    [user_id] => 1
                )

        )
...
...

)
  • 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-13T13:38:48+00:00Added an answer on May 13, 2026 at 1:38 pm

    I’m not sure what the array indexes represent but I’ll leave them in just in case they’re useful to you. The answer is basically the same as Alix’s with a check to ensure you actually have a nested array:

    foreach ($array as $day => $events) {
        if (is_array($events)) {
            foreach ($events as $event) {
                echo $day;         // outputs 29 (same as $event->day)
                echo $event->user; // outputs shin
                echo $event->eventContent;
                echo $event->eventTitle;
                echo $event->id;
                // etc, etc, etc.
            }
        } 
    }
    

    Notice the difference between the outer foreach loop and the inner loop. The outer one is retrieving both the array key and value whereas the inner loop is only returning the array value.

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

Sidebar

Related Questions

I have the following php code that gets a serialized array from a mysql
I have the following php code: $seasons = array(Autumn, Winter, Spring, Summer); Now I
I have the following array response from a server to an android app. [
I have the following array(in python): arr= ['\n', ' a#B\n', ' c#D\n'] Now I
I have a problem running another file from php. I want my php params
I have the following query: $select = $this->getDao()->select() ->from( array(new Zend_Db_Expr('FROM_UNIXTIME(expiration)')) ); The getDao
Imagine I have the following SQL query: SELECT id,name FROM user WHERE id IN
I have a php script that returns just plain text without any html. Now
If I want to get a customer's email address from a database, the following
I have the folowing array: outerarray{ id: 20154, from: { name: xyz, id: 10004

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.