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 petersprc on 02/07/07 14:53

Hi,

Please try: return recurseArray($arrayValue);

Should do the trick.

On Feb 7, 9:49 am, "Aggelos" <djje...@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);
> }
> }
> elseif(is_object($array)) {
> $object = $array;
> return $object;
> }
>
> }
>
> the problem with that is that when i try to do
> $_product = recurseArray($productArray)
> print_r($_product);
>
> it won't pring anything. But if i do the pring inside the method like
> that
> ...
> elseif(is_object($array)) {
> $object = $array;
> print_r($object)
> return $object;
> }
> ...
> it will print my object.
>
> Do you know why is this happening ?
> It makes me crazy !!!
> Thanks, Angelos.

 

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

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