Re: [PHP4BETA] problem passing arrays by reference using array_walk

From: Date: Mon, 27 Mar 2000 14:34:32 +0000
Subject: Re: [PHP4BETA] problem passing arrays by reference using array_walk
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-12671@lists.php.net to get a copy of this message
On Mon, 27 Mar 2000, Phil Driscoll wrote: > function SetArray($Item,$Key,&$Array) > { > echo("current value=$Array[$Key]<br>"); > $Array[$Key]="bar"; > echo("new value=$Array[$Key]<br>"); > } > > $Array1[0]="dont care for now"; > $Array2[0]="foo"; > array_walk($Array1,"SetArray",$Array2); > echo($Array2[0]); > > Outputs: > current value=foo > new value=bar > foo > > > So, am I doing something wrong, or does the 'pass by reference' not make it > through the array_walk process? How come you are not using $Item in SetArray()? That's the current item that you are supposed to work on. $Array2 is just userdata. -Andrei * I don't mind going nowhere as long as it's an interesting path. *

« previous php.version4 (#12671) next »