• <tfoot id='t21VP'></tfoot>

  • <legend id='t21VP'><style id='t21VP'><dir id='t21VP'><q id='t21VP'></q></dir></style></legend>

        <small id='t21VP'></small><noframes id='t21VP'>

        <i id='t21VP'><tr id='t21VP'><dt id='t21VP'><q id='t21VP'><span id='t21VP'><b id='t21VP'><form id='t21VP'><ins id='t21VP'></ins><ul id='t21VP'></ul><sub id='t21VP'></sub></form><legend id='t21VP'></legend><bdo id='t21VP'><pre id='t21VP'><center id='t21VP'></center></pre></bdo></b><th id='t21VP'></th></span></q></dt></tr></i><div id='t21VP'><tfoot id='t21VP'></tfoot><dl id='t21VP'><fieldset id='t21VP'></fieldset></dl></div>
        • <bdo id='t21VP'></bdo><ul id='t21VP'></ul>

        如何遍历php中的对象

        时间:2023-09-23

          1. <legend id='26ZP7'><style id='26ZP7'><dir id='26ZP7'><q id='26ZP7'></q></dir></style></legend>

            <small id='26ZP7'></small><noframes id='26ZP7'>

            • <tfoot id='26ZP7'></tfoot>
                <bdo id='26ZP7'></bdo><ul id='26ZP7'></ul>
                <i id='26ZP7'><tr id='26ZP7'><dt id='26ZP7'><q id='26ZP7'><span id='26ZP7'><b id='26ZP7'><form id='26ZP7'><ins id='26ZP7'></ins><ul id='26ZP7'></ul><sub id='26ZP7'></sub></form><legend id='26ZP7'></legend><bdo id='26ZP7'><pre id='26ZP7'><center id='26ZP7'></center></pre></bdo></b><th id='26ZP7'></th></span></q></dt></tr></i><div id='26ZP7'><tfoot id='26ZP7'></tfoot><dl id='26ZP7'><fieldset id='26ZP7'></fieldset></dl></div>
                  <tbody id='26ZP7'></tbody>

                  本文介绍了如何遍历php中的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我对对象不太熟悉,我通常使用脚本将它们转换为数组,但我认为是时候开始学习这个了,所以我问我如何遍历对象数组并拉出我需要的具体信息,返回内容的示例如下.

                  I am not too familiar with objects, i usually convert them to arrays using a script, but i thought it was time to man up and learn this, so i am asking how can i loop through an array of objects and pull out the specific information i need, the example of what is being returned is below.

                  [2] => stdClass Object
                          (
                              [id_str] => 152240682071900161
                              [in_reply_to_status_id] => 
                              [contributors] => 
                              [place] => 
                              [truncated] => 
                              [geo] => 
                              [favorited] => 
                              [created_at] => Thu Dec 29 04:13:01 +0000 2011
                              [user] => stdClass Object
                                  (
                                      [id_str] => 71876190
                                      [contributors_enabled] => 
                                      [lang] => en
                                      [protected] => 
                                      [url] => http://www.imdb.com/name/nm0000362/
                                      [default_profile] => 1
                                      [profile_use_background_image] => 1
                                      [name] => Danny DeVito
                                      [default_profile_image] => 
                                      [friends_count] => 14
                                      [profile_text_color] => 333333
                                      [statuses_count] => 5361
                                      [profile_background_image_url] => http://a0.twimg.com/images/themes/theme1/bg.png
                                      [utc_offset] => -28800
                                      [description] => I'm an actor, director and producer. 
                                      [is_translator] => 
                                      [created_at] => Sat Sep 05 19:44:48 +0000 2009
                                      [profile_link_color] => 0084B4
                                      [following] => 1
                                      [profile_background_image_url_https] => https://si0.twimg.com/images/themes/theme1/bg.png
                                      [favourites_count] => 8
                                      [follow_request_sent] => 
                                      [geo_enabled] => 1
                                      [profile_background_color] => C0DEED
                                      [profile_background_tile] => 
                                      [followers_count] => 1784732
                                      [profile_image_url] => http://a2.twimg.com/profile_images/400232403/Photo_6_normal.jpg
                                      [screen_name] => DannyDeVito
                                      [show_all_inline_media] => 
                                      [profile_sidebar_fill_color] => DDEEF6
                                      [profile_image_url_https] => https://si0.twimg.com/profile_images/400232403/Photo_6_normal.jpg
                                      [listed_count] => 20918
                                      [notifications] => 
                                      [location] => Los Angeles
                                      [id] => 71876190
                                      [verified] => 1
                                      [time_zone] => Pacific Time (US & Canada)
                                      [profile_sidebar_border_color] => C0DEED
                                  )
                  
                              [in_reply_to_user_id] => 
                              [retweet_count] => 10
                              [in_reply_to_screen_name] => 
                              [in_reply_to_status_id_str] => 
                              [possibly_sensitive] => 
                              [retweeted] => 
                              [source] => WhoSay
                              [in_reply_to_user_id_str] => 
                              [coordinates] => 
                              [id] => 1.52240682072E+17
                              [text] => #Trollfoot Maroma http://t.co/4MvCYIFe
                          )
                  
                      [3] => stdClass Object
                          (
                              [id_str] => 152240419344879616
                              [in_reply_to_status_id] => 
                              [contributors] => 
                              [place] => 
                              [truncated] => 
                              [geo] => 
                              [favorited] => 
                              [created_at] => Thu Dec 29 04:11:59 +0000 2011
                              [user] => stdClass Object
                                  (
                                      [id_str] => 71876190
                                      [default_profile] => 1
                                      [contributors_enabled] => 
                                      [lang] => en
                                      [protected] => 
                                      [url] => http://www.imdb.com/name/nm0000362/
                                      [profile_use_background_image] => 1
                                      [name] => Danny DeVito
                                      [default_profile_image] => 
                                      [friends_count] => 14
                                      [profile_text_color] => 333333
                                      [statuses_count] => 5361
                                      [profile_background_image_url] => http://a0.twimg.com/images/themes/theme1/bg.png
                                      [utc_offset] => -28800
                                      [description] => I'm an actor, director and producer. 
                                      [is_translator] => 
                                      [created_at] => Sat Sep 05 19:44:48 +0000 2009
                                      [profile_link_color] => 0084B4
                                      [following] => 1
                                      [profile_background_image_url_https] => https://si0.twimg.com/images/themes/theme1/bg.png
                                      [favourites_count] => 8
                                      [follow_request_sent] => 
                                      [geo_enabled] => 1
                                      [profile_background_color] => C0DEED
                                      [profile_background_tile] => 
                                      [followers_count] => 1784725
                                      [profile_image_url] => http://a2.twimg.com/profile_images/400232403/Photo_6_normal.jpg
                                      [screen_name] => DannyDeVito
                                      [show_all_inline_media] => 
                                      [profile_sidebar_fill_color] => DDEEF6
                                      [profile_image_url_https] => https://si0.twimg.com/profile_images/400232403/Photo_6_normal.jpg
                                      [listed_count] => 20918
                                      [notifications] => 
                                      [location] => Los Angeles
                                      [id] => 71876190
                                      [verified] => 1
                                      [time_zone] => Pacific Time (US & Canada)
                                      [profile_sidebar_border_color] => C0DEED
                                  )
                  
                              [in_reply_to_user_id] => 
                              [retweet_count] => 15
                              [in_reply_to_screen_name] => 
                              [in_reply_to_status_id_str] => 
                              [possibly_sensitive] => 
                              [retweeted] => 
                              [source] => WhoSay
                              [in_reply_to_user_id_str] => 
                              [coordinates] => 
                              [id] => 1.52240419345E+17
                              [text] => #Trolltoll Maroma http://t.co/Egv9syon
                          )
                  

                  推荐答案

                  你不需要将它们转换成任何东西.

                  you dont need to convert them to anything.

                  foreach 循环可以正常工作,如下一般:

                  foreach loop would work fine with you as follows in generic:

                  foreach ($objects as $obj) {
                     echo $obj->property;
                  }
                  

                  对于内部对象,这将起作用:

                  for a inner object this would work:

                  foreach ($objects as $obj){
                        echo $obj->user->description;
                  }
                  

                  这篇关于如何遍历php中的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在 foreach 循环中获取当前数组索引? 下一篇:如何使用foreach从数据库表中获取数据——

                  相关文章

                  最新文章

                        <bdo id='h7n6D'></bdo><ul id='h7n6D'></ul>

                    1. <small id='h7n6D'></small><noframes id='h7n6D'>

                      <legend id='h7n6D'><style id='h7n6D'><dir id='h7n6D'><q id='h7n6D'></q></dir></style></legend>
                    2. <i id='h7n6D'><tr id='h7n6D'><dt id='h7n6D'><q id='h7n6D'><span id='h7n6D'><b id='h7n6D'><form id='h7n6D'><ins id='h7n6D'></ins><ul id='h7n6D'></ul><sub id='h7n6D'></sub></form><legend id='h7n6D'></legend><bdo id='h7n6D'><pre id='h7n6D'><center id='h7n6D'></center></pre></bdo></b><th id='h7n6D'></th></span></q></dt></tr></i><div id='h7n6D'><tfoot id='h7n6D'></tfoot><dl id='h7n6D'><fieldset id='h7n6D'></fieldset></dl></div>
                    3. <tfoot id='h7n6D'></tfoot>