我在一个名为$result
以下是此变量的var_dump()
:
array(3) {
[0]=>
object(stdClass)#23 (25) {
["procedure_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"
["comment"]=>
string(0) ""
["patient_age"]=>
string(2) "34"
["patient_height"]=>
string(4) "1.34"
["patient_weight"]=>
string(2) "45"
["patient_gender"]=>
string(4) "Male"
["name"]=>
string(10) "Cardiology"
["procedure_name_id"]=>
string(1) "1"
["procedure_name"]=>
string(5) "IVH 2"
["procedure_description"]=>
string(0) ""
["dosage_emitted"]=>
NULL
["dosage_absorbed"]=>
NULL
["dosage_period"]=>
NULL
["event_id"]=>
string(1) "1"
["time"]=>
string(8) "12:34:00"
["success"]=>
string(3) "Yes"
["event"]=>
string(5) "start"
}
[1]=>
object(stdClass)#24 (25) {
["procedure_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"
["comment"]=>
string(0) ""
["patient_age"]=>
string(2) "34"
["patient_height"]=>
string(4) "1.34"
["patient_weight"]=>
string(2) "45"
["patient_gender"]=>
string(4) "Male"
["name"]=>
string(10) "Cardiology"
["procedure_name_id"]=>
string(1) "1"
["procedure_name"]=>
string(5) "IVH 2"
["procedure_description"]=>
string(0) ""
["dosage_emitted"]=>
NULL
["dosage_absorbed"]=>
NULL
["dosage_period"]=>
NULL
["event_id"]=>
string(1) "2"
["time"]=>
string(8) "14:50:00"
["success"]=>
string(3) "Yes"
["event"]=>
string(3) "sds"
}
[2]=>
object(stdClass)#25 (25) {
["procedure_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"
["comment"]=>
string(0) ""
["patient_age"]=>
string(2) "34"
["patient_height"]=>
string(4) "1.34"
["patient_weight"]=>
string(2) "45"
["patient_gender"]=>
string(4) "Male"
["name"]=>
string(10) "Cardiology"
["procedure_name_id"]=>
string(1) "1"
["procedure_name"]=>
string(5) "IVH 2"
["procedure_description"]=>
string(0) ""
["dosage_emitted"]=>
NULL
["dosage_absorbed"]=>
NULL
["dosage_period"]=>
NULL
["event_id"]=>
string(1) "3"
["time"]=>
string(8) "15:00:00"
["success"]=>
string(3) "Yes"
["event"]=>
string(3) "end"
}
}
我想访问实例[“dosage_id”]。如何将代码编写到此>
我尝试了所有这些:
$result["dosage_id"];
$result[0]["dosage_id"];
$result->"dosage_id";
由于
答案 0 :(得分:2)
数组结果是对象,如
array(3) {
[0]=>
object(stdClass)#23 (25) {
的信息。由于此类具有公共属性,$result[0]->dosage_id
将检索第一个对象的dosage_id
属性值。
答案 1 :(得分:2)
喜欢这个
$result[0]->dosage_id
$result[0]
是一个对象,以及您使用->
答案 2 :(得分:0)
试试这个:$result[0]->dosage_id;