Array members won't save
<p>i learn php and stuck in trouble with next code:</p>

<pre><code>    $people = new people();
    $people-&gt;getByNumber($value[0]);    
    $peoples = array();
    $count_people = 5;
    for($i=1; $i&lt;=$count_people; $i++)
    {
        $people-&gt;getByNumber($i);
        $peoples[$i] = $people;
        print_r($peoples[$i]);
    }
    print_r($peoples);
</code></pre>

<p>so after cycle "for" <code>$peoples</code> dont show any information and <code>print_r</code> tell, that array consist of empty values (but keys exists). While cycle work, inside it <code>print_r</code> show me right pair key->value. How can i repair it to use right <code>$peoples</code> after cycle?</p>

<p>upd:
in for-loop by <code>print_r($peoples[$i]);</code> i can see that:     </p>

<pre><code>people Object
 (
    [id] =&amp;gt; 1
    [age] =&amp;gt; 19
    [short_name] =&amp;gt; Jhon
    [full_name] =&amp;gt; Jhon Persh
    [image] =&amp;gt; 
 )
</code></pre>

<p>but after for-loop <code>$peoples</code> contains only:</p>

<pre><code>Array
(
    [1] =&amp;gt; people Object
        (
            [id] =&amp;gt; 
        [age] =&amp;gt; 
        [short_name] =&amp;gt; 
        [full_name] =&amp;gt; 
        [image] =&amp;gt; 
        )

    [2] =&amp;gt; people Object
        (
            [id] =&amp;gt; 
        [age] =&amp;gt; 
        [short_name] =&amp;gt; 
        [full_name] =&amp;gt; 
        [image] =&amp;gt;  
        )

    [3] =&amp;gt; people Object
        (
            [id] =&amp;gt; 
        [age] =&amp;gt; 
        [short_name] =&amp;gt; 
        [full_name] =&amp;gt; 
        [image] =&amp;gt; 
        )

    [4] =&amp;gt; people Object
        (
            [id] =&amp;gt;
        [age] =&amp;gt; 
        [short_name] =&amp;gt; 
        [full_name] =&amp;gt; 
        [image] =&amp;gt;  
        )

    [5] =&amp;gt; people Object
        (
          [id] =&amp;gt; 
          [age] =&amp;gt; 
          [short_name] =&amp;gt; 
          [full_name] =&amp;gt; 
          [image] =&amp;gt; 
        )

)
</code></pre>

<p>upd2:</p>

<pre><code>public function getByNumber($id)
    {
        $classProperty = get_object_vars($this);
        foreach ($classProperty as $key=&gt;$value)
            $member[] = $key;

        $data = //random data generation;
        foreach ($member as $key =&gt;$field)
        {
            $this-&gt;$field = $data[$field];
        }
    }
</code></pre>