Objects and Arrays

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TKirahvi

    Objects and Arrays

    Why can't I create Objects in an Array within for/while loop?

    If I have:

    Code:

    $galleries = array();

    while( $db->next_record( ) )
    {
    $foo = $db->f('id');
    $galleries[] = new Gallery($foo);
    }


    Database query returns two id's and galleries array should then
    contain two Gallery Objects but it contains only the first one.

    If I do it like this, it works fine:

    Code:

    $galleries[] = new Gallery(1);
    $galleries[] = new Gallery(2);


    I have PHP 5.1.6

    Thanks in advance

  • Willem Bogaerts

    #2
    Re: Objects and Arrays

    Why can't I create Objects in an Array within for/while loop?

    Well, why can't you? I mean, if you don't say what goes wrong, how can
    we help?

    --
    Willem Bogaerts

    Application smith
    Kratz B.V.

    Comment

    Working...