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 Rik on 02/07/07 15:06

Aggelos <djjelly@gmail.com> wrote:

> Hello,
> I am using php4
> And I have a class product
> I create an array of productObjects that has 2 dimensions.
> Generraly I am sorting my objects inside arrays and I need to some how=

> recurse those arrays to get to the objects.
>
> To do that I am using the following method recurseArray()
>
> function recurseArray($array) {
> if(is_array($array)) {
> foreach($array as $arrayValue) {
> recurseArray($arrayValue);

This won't do anything, you returned objects are cast in the void....

How would you like your objects returned by the function? In case of a =

flat array (which I suspect):


function objects_from_array($var){
$return =3D array();
if(is_object($var)){
$return[] =3D $var;
}
if(is_array($var)){
$return =3D array_merge($return,objects_from_array($var));
}
return $return;
}
-- =

Rik Wasmus

 

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

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