problems with array_walk
| From: | Sergio Garcia Murillo | Date: | Thu, 13 Apr 2000 10:59:46 +0000 |
| Subject: | problems with array_walk | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-13492@lists.php.net to get a copy of this message | ||
I have just tried the PHP4.0RC1 and i have seen one weird behaviour
First of all.. i have to reset the array before doing an array walk, and
second, it seems to make a copy of the value inestead of giving it..
For example this code
<?
class x {
var $foo;
function x ()
{
$this->foo=0;
}
function change()
{
$this->foo=1;
}
function show ()
{
echo $this->foo."<br>\n";
}
}
function change($o)
{
$o->change();
}
function show($o)
{
$o->show();
}
$obj[1] = new x();
$obj[2] = new x();
array_walk($obj,'change');
reset($obj);
array_walk($obj,'show');
?>
the output is 0 0 instead of 1 1 is this the eay it's supposed to work or
it's a bug (in php3 i have none of the
two problems)
Greetings
Sergio