从std classin php中获取std类值

时间:2016-10-25 04:34:06

标签: php codeigniter-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
        )

)

如何从Prop_type

获取stdclass

2 个答案:

答案 0 :(得分:2)

选中此项,您可以访问所有Prop_type's

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

创建Prop_type's

数组
$propData =array();
foreach($data as $key=>$row){
    if (is_int($key)) {
        $propData[] = $row->Prop_type;
    }
}

答案 1 :(得分:0)

echo $array->0->Prop_type;