Re: CLASS/Object lifetime - > Solution
| From: | roger helgesen | Date: | Wed, 22 Feb 2006 09:05:15 +0000 |
| Subject: | Re: CLASS/Object lifetime - > Solution | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-230888@lists.php.net to get a copy of this message | ||
function fyll_sub_konto($pv){
foreach($this->subposter AS $konto=>$kt){
$kontoen=& $this->subposter[$konto];
$kontoen->fyll_fra_post($pv);
$kontoen->endre();
}
}
the line
$kontoen=& $this->subposter[$konto];
solved all
roger
roger helgesen wrote:
The function that gives me trouble --------- function fyll_sub_konto($pv){foreach($this->subposter AS $konto){ $konto->fyll_fra_post($pv); }} ------------- $this->subposter is the array of CLASS2 function fyll_fra_post($post_vars){echo "(gruppe)class = ".get_class($this) ."<br>\n"; $teller=0; foreach($this->poster AS $post=>$verd){ $best="bestilt_".$post; $avik="avvik_".$post; $fakt="faktura_".$post; $this->poster[$post]["bestilt"]=$post_vars[$best]; $this->poster[$post]["avvik"]=$post_vars[$avik]; $this->poster[$post]["faktura"]=$post_vars[$fakt]; } $this->endret='ja'; $this->sett_sum();} If I print the data (after setting the new data) inside 'fyll_fra_post' it puts out the new data. If I do the same from 'fyll_sub_konto' (after foreach) it gives me the old data.