另一个PHP数组循环的问题 [英] Another php array looping question

查看:187
本文介绍了另一个PHP数组循环的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一直缠斗与此一对什么似乎像永远。

Been battling with this one for what seems, like forever.

我有一个数组:

$url_array

它包含以下信息:

It contains this info:

Array ( 
   [ppp] => Array ( 
      [0] => stdClass Object ( 
         [id] => 46660 
         [entity_id] => 0 
         [redirect_url] => http://www.google.com 
         [type] => Image 
      ) 
      [1] => stdClass Object ( 
         [id] => 52662 
         [entity_id] => 0 
         [pixel_redirect_url] => http://www.yahoo.com 
         [type] => Image 
      ) 
      [2] => stdClass Object ( 
         [id] => 53877 
         [entity_id] => 0 
         [redirect_url] => http://www.msn.com 
         [pixel_type] => Image 
      ) 
   ) 
   [total_count] => 3 
)

我需要通过它循环,做事每个变量。我能得到这个工作:

I need to loop through it, and do things to each variable. I can get this to work:

foreach ($piggies_array as $key => $value) {
$id = $value[0]->id;
$redirect_url = $value[0]->redirect_url; }

不令人吃惊,这只是附和这些变量的第一个值,但不管我怎么努力我不能打通循环:

Not unsurprisingly, it's only echoing the first value of those variables, but no matter what I try I cannot get it to loop through:

$value->redirect_url;
$value=>redirect_url;

我想AP preciate任何帮助。

I would appreciate any help.

推荐答案

这应该做的伎俩:

foreach ($url_array['ppp'] as $key => $object) {
    echo $object->redirect_url;
}

这篇关于另一个PHP数组循环的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆