php从类内部的数组中读取

时间:2016-11-10 11:19:49

标签: php json class

当我使用print_r作为API URL的响应时,得到了以下结果:

public void SlideToY() {
    Animation slide = null;
    slide = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
            Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
            -5.0f, Animation.RELATIVE_TO_SELF, 0.0f);

    slide.setDuration(2000);
    slide.setFillAfter(true);
    slide.setFillEnabled(true);
    img.startAnimation(slide);

    slide.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {


        }

    });

}

问题是我想循环读取 MessageID 的值 我怎么能这样做?

1 个答案:

答案 0 :(得分:2)

如此简单的使用foreach用于遍历每个键/值对

foreach($your_variable->Messages as $row) 
 { 
   echo $row->MessageID; 
 }