You are here: Re: Recurse an array with an object/s « PHP Programming Language « IT news, forums, messages
Re: Recurse an array with an object/s

Posted by Aggelos on 02/07/07 15:31

> function objects_from_array($var){
> $return = array();
> if(is_object($var)){
> $return[] = $var;
> }
> if(is_array($var)){
> $return = array_merge($return,objects_from_array($var));
> }
> return $return;}
>
That function will also enter an endless loop like petesprc
We need to loop inside the array to get the next dimension... don't
we ? so when you do arraymerge the $var should be the second dimension
of the array in the first call of the function.

Isn't that right ?
So I suppose I need to have a foreach loop

my array is like that
$productArray[$productTypeId][$productId][$published] = new
objectProduct();

so for that i would do 3 nested foreach loops ...
But I want to do that using a function to get to the objectProduct.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация