Another php array looping question

Posted by Dan on Stack Overflow See other posts from Stack Overflow or by Dan
Published on 2011-01-07T14:41:02Z Indexed on 2011/01/07 14:53 UTC
Read the original article Hit count: 187

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

I have an array:

$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;

I would appreciate any help.

© Stack Overflow or respective owner

Related posts about php

Related posts about arrays