从PHP中的一个标准类(std class)获取标准类值

3
stdClass Object
(
    [id_pro_alert] => 155
    [User_Id] => 252
    [Pro_Id] => 329
    [alertmethod] => daily
    [Alertname] => xcxv
    [name] => cyriac
    [email] => cyriac@tewve.com
    [date] => 2016-21-10 09:20:26
    [mobile] => 
    [comments] => 
    [Alert_Id] => 329
    [Prop_Purpose] => lease
    [Min_Area] => 500
    [Max_Area] => 1000
    [Area_unit] => Sq.ft
    [Min_cost] => 1000
    [Max_cost] => 10000
    [City] => kochi
    [Create_Date] => 2016-10-17 12:59:14
    [Update_Date] => 2016-10-17 12:59:14
    [Status] => Active
    [0] => stdClass Object
        (
            [Prop_type] => Agricultural Land
        )

    [1] => stdClass Object
        (
            [Prop_type] => Office in IT park
        )

    [2] => stdClass Object
        (
            [Prop_type] => Business center
        )

)

如何从 stdclass 中获取 Prop_type 的值


感谢 Anant 的回答。但是它显示错误。 - cyriac
2个回答

2

请查看,您可以访问所有Prop_type

foreach($data as $key=>$row){
    if (is_int($key)) {
        echo $row->Prop_type;
    }
}

创建一个由Prop_type组成的数组。
$propData =array();
foreach($data as $key=>$row){
    if (is_int($key)) {
        $propData[] = $row->Prop_type;
    }
}

0
echo $array->0->Prop_type;

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接