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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:57:49+00:00 2026-05-24T07:57:49+00:00

I think I am either just stupid or something but I still can’t get

  • 0

I think I am either just stupid or something but I still can’t get my head around them.

I am trying to access “patient_age” from this variable $result.

Here is the var dump.

array(1) {
  ["intervention"]=>
  array(1) {
    [0]=>
    object(stdClass)#23 (21) {
     ["intervention_id"]=>
      string(1) "1"
      ["patient_id"]=>
      string(1) "1"
      ["name_id"]=>
      string(1) "1"
      ["department_id"]=>
      string(1) "1"
      ["dosage_id"]=>
      NULL
      ["edocument"]=>
      string(10) "Bruce1.jpg"
      ["user_id"]=>
      string(1) "0"
      ["duration"]=>
      string(8) "02:26:00"
      ["submitted"]=>
      string(19) "2011-07-31 19:56:29"
      ["intervention_comment"]=>
      NULL
      ["patient_age"]=>
      string(2) "34"
      ["patient_height"]=>
      string(4) "1.34"
      ["patient_weight"]=>
      string(2) "45"
      ["patient_gender"]=>
      string(4) "Male"
      ["department_name"]=>
      string(10) "Cardiology"
      ["intervention_name_id"]=>
      string(1) "1"
      ["intervention_name"]=>
      string(5) "IVH 2"
      ["intervention_description"]=>
      string(0) ""
      ["dosage_emitted"]=>
      NULL
      ["dosage_absorbed"]=>
      NULL
      ["dosage_period"]=>
      NULL
    }
  }
}

I have tried :

$result[0]->patient_age;
$result[1]->patient_age;
$result['intervention']->patient_age;
$result['intervention'][0]->patient_age;

Hopefully someone could give me the answer but also explain how they came to this answer as all the other Stackoverflow questions they just give the solution but not the method.

Anyone got any tips how to navigate nested variables.

Thanks

  • 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-24T07:57:50+00:00Added an answer on May 24, 2026 at 7:57 am

    It should be your last example. It’s not that hard, really. $result is an array which contains a single element, with the key “intervention”. You can access an array’s elements by using [ and ]. So, with $result[‘intervention’], you get an array that also contains a single element: the element at key 0, which is an instance of stdClass. You can reach that by using $result[‘intervention’][0]. If you want to get the patient_age from that stdClass, you can access the instance variables with the ->. So, this should work:

    echo $result['intervention'][0]->patient_age;
    

    The following would result in $patient being the stdClass instance, which you can then retrieve patient_age from:

    $patient = $result['intervention'][0];
    echo $patient->patient_age;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Probably a stupid question but I'm still trying to wrap my head around nHibernate.
Now, this may be really stupid. But can we deploy a Java Swing Application
These methods are laughably stupid, IMO, but I want to get a feel for
Just want to make sure one thing. In a windows machine (either a desktop
I'm a little confused as to which one I should use. I think either
Think my problem is I am trying to sum a count in the same
I think that handlers in android are tools to get different objects that are
I think I have a basic understanding of this, but am hoping that someone
Forgive me if my question is stupid, but I'm not a web programmer and
I just invented a stupid little helper function: def has_one(seq, predicate=bool): Return whether there

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.