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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:04:43+00:00 2026-06-11T00:04:43+00:00

Ok, here we go. I hope I explain this correctly. I have an object

  • 0

Ok, here we go. I hope I explain this correctly.

I have an object that i’d like to loop through to obtain both the key and value. Here is an example of the object I’m receiving. Thanks in advance for any help or ideas.

    Array
(
    [0] => stdClass Object
        (
            [id] => 93
            [RecordGUID] => 
            [txtEmplid] => 0134754
            [txtFname] => 
            [txtLname] => 
            [txtMname] => 
            [txtEmail] => 
            [txtSecEmail] => 
            [txtPhoneNo] => 4046565454
            [drpMajor] => 
            [drpStatus] => 
            [regmain] => 
            [chkDental] => 0
            [chkDO] => 
            [chkMD] => 
            [chkMDPHD] => 
            [chkNursin] => 
            [chkOPT] => 
            [chkPA] => 
            [chkPH] => 
            [chkPharm] => 
            [chkPOD] => 
            [chkPostBac] => 
            [chkVet] => 
        )

)

I basically need to loop through the above info getting both the key and value. For example:

id=93
RecordGUID=
txtEmplid=0134754

and so on.

Again, thanks in advance for any answers.

UPDATE for DBF
Here is what I get when I use your code snippt:

int(0)
object(stdClass)#27 (24) {
  ["id"]=>
  string(2) "93"
  ["RecordGUID"]=>
  NULL
  ["txtEmplid"]=>
  string(7) "0134754"
  ["txtFname"]=>
  string(0) ""
  ["txtLname"]=>
  string(0) ""
  ["txtMname"]=>
  string(0) ""
  ["txtEmail"]=>
  string(0) ""
  ["txtSecEmail"]=>
  string(0) ""
  ["txtPhoneNo"]=>
  string(10) "4045506561"
  ["drpMajor"]=>
  NULL
  ["drpStatus"]=>
  NULL
  ["regmain"]=>
  NULL
  ["chkDental"]=>
  string(1) "0"
  ["chkDO"]=>
  NULL
  ["chkMD"]=>
  NULL
  ["chkMDPHD"]=>
  NULL
  ["chkNursin"]=>
  NULL
  ["chkOPT"]=>
  NULL
  ["chkPA"]=>
  NULL
  ["chkPH"]=>
  NULL
  ["chkPharm"]=>
  NULL
  ["chkPOD"]=>
  NULL
  ["chkPostBac"]=>
  NULL
  ["chkVet"]=>
  NULL
}
  • 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-06-11T00:04:45+00:00Added an answer on June 11, 2026 at 12:04 am

    use get_object_vars ( object $object )

    $vars = get_object_vars ( $object );
    foreach($vars as $key=>$value) {
      var_dump($key);
      var_dump($value);
    }
    

    or just iterate the object itself

    foreach($object as $key=>$value) {
      var_dump($key);
      var_dump($value);
    }
    

    — edit 2

    Here you’ll have the keys and values in one line

    $string = "";
    foreach($regs as $object) {
      foreach($object as $key=>$value) {
        $string += "{$key}={$value} ";
      }
    }
    echo $string;
    

    if this is not what you need, I’m clueless ..

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

Sidebar

Related Questions

OK, I hope I explain this one correctly. I have a struct: typedef struct
First-timer here, I hope I explain this well enough... PHP/Smarty, I'm working on a
Ok this is hard to explain, but here goes. I have a 3D list
I have tried solving this problem by posting other related questions here that focused
Here's an interesting one... hope I can explain it well... I have a collection
Not sure how to explain this,hope you understand me.. Here is the problem :
I hope I can explain this clearly. I have a table, lets call it
I'm new here and I hope anyonte can help me. I have WCF Service
I thought I'd post here in the hope that maybe someone with MVVM expertise
This is my first time here so I hope I post this question at

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.