dpp66953 2016-10-26 09:09
浏览 30
已采纳

从嵌套对象中检索特定值

How can I get Pro_photourl and id values from the following std class?

Array (
  [0] => stdClass Object (
    [Pro_photourl] => http://122.165.117.41/Commercial_Affairs/api/uploads/hd-panasonic-corporate16.jpg 
    [Pro_photoid] => 1150
  ) 
  [1] => stdClass Object (
    [Pro_photourl] => http://122.165.117.41/Commercial_Affairs/api/uploads/beautiful-wallpaper-3948.jpg
    [Pro_photoid] => 1150
  )
  [2] => stdClass Object (
    [id] => 1150
    [Pro_userid] => 252
    [Pro_Listingtype] => Paid Listing
    [Pro_membertype] => Owner
    [Pro_purpose] => Rent
    [Pro_type] => Business center
    [Pro_subttype] => Commercial
    [Pro_city] => Kochi
    [Pro_locality] => Kerala, India
    [Pro_society] =>
    [Pro_addr_next] => kochi
    [Pro_facility_washroom] =>
    [Pro_facility_rooms] =>
    [Pro_facility_rating] =>
    [Pro_facility_balcony] =>
    [Pro_facility_pooja_Room] =>
    [Pro_facility_study_Room] =>
    [Pro_facility_servant_Room] =>
    [Pro_facility_others] =>
    [Pro_furnishing] => Yes
    [Pro_numberofproperty] => 1
    [Pro_buildarea] => 700
    [Pro_buildareaunit] => Sq.ft
    [Pro_plotarea] => 0
    [Pro_Plotareaunit] => NA
    [Pro_carpetarea] =>
    [Pro_carpetareaunit] =>
    [Pro_price_crore] =>
    [Pro_price_lakhs] =>
    [Pro_price_thousand] =>
    [Pro_pricefull] => 1000
    [Pro_allprice] => YES
    [Pro_pricenogotable] =>
    [Pro_maintcharge] => 0
    [Pro_maint_pmtmethod] =>
    [Pro_transtype] => NA
    [Pro_ownershiptype] => freehold
    [Pro_availability] => readyToMove
    [Pro_possessionperiod] => NA
    [Pro_photoid] =>
    [Pro_featuresid] =>
    [Pro_description] => Test
    [Pro_phonehide_disp] => yes
    [Pro_regdate] => 2016-09-30 18:43:58
    [Pro_bookingamt] =>
    [Pro_anualduepayable] =>
    [Pro_distfromairport] =>
    [Pro_distfromHospital] =>
    [Pro_distfromrailwaystation] =>
    [Pro_distfromATM] =>
    [Pro_Distfromcitycenter] =>
    [Pro_distfromschool] =>
    [Pro_keylandmark] =>
    [Pro_adlcomments] =>
    [Pro_verified] => Yes
    [Pro_status] => Active
    [Pro_unitprice] => 10000
    [Pro_age] =>
    [Expiry_Date] => 0
  )
)
  • 写回答

3条回答 默认 最新

  • dqch34769 2016-10-26 09:23
    关注

    If you want to get values of Pro_photourl and id from std class, you can just use:

    <?php
    foreach ($yourArr as $key => $value) {
        if(isset($value->Pro_photourl)){
            echo $value->Pro_photourl; // will print photourl if exist in object
        }
        if(isset($value->id)){
            echo $value->id; // will print id if exist in object.
        }    
    }
    ?>
    

    Because as per your array you have three index, two indexes having Pro_photourl and only one index having id value.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?
  • ¥15 关于#vue.js#的问题:修改用户信息功能图片无法回显,数据库中只存了一张图片(相关搜索:字符串)
  • ¥15 texstudio的问题,
  • ¥15 spaceclaim模型变灰色
  • ¥15 求一份华为esight平台V300R009C00SPC200这个型号的api接口文档
  • ¥15 字符串比较代码的漏洞
  • ¥15 欧拉系统opt目录空间使用100%
  • ¥15 ul做导航栏格式不对怎么改?