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
}
use
get_object_vars ( object $object )or just iterate the object itself
— edit 2
Here you’ll have the keys and values in one line
if this is not what you need, I’m clueless ..