Bug #17781 Updated: Array assignment through method
| From: | hholzgra@php.net | Date: | Sun, 16 Jun 2002 15:08:50 +0000 |
| Subject: | Bug #17781 Updated: Array assignment through method | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-10744@lists.php.net to get a copy of this message | ||
ID: 17781
Updated by: hholzgra@php.net
Reported By: Oliver.Siegmar@xams.org
Status: Bogus
Bug Type: Class/Object related
Operating System: Linux
PHP Version: 4.1.2
New Comment:
... but you could use eval() ...
Previous Comments:
------------------------------------------------------------------------
[2002-06-16 09:07:49] sander@php.net
This is just not possible. You can't specify a value of an array using
variable variables.
------------------------------------------------------------------------
[2002-06-16 08:59:13] Oliver.Siegmar@xams.org
<?php
class testclass {
function assign($var, $value) {
$this->$var = $value;
}
}
$testobj = new testclass();
$testobj->testvar = 20;
$testobj->assign("testvar", 30);
echo $testobj->testvar; // Result = 30 - very good!
$testobj->testarray["dim1"]["dim2"] = 20;
$testobj->assign("testarray[dim1][dim2]", 30);
echo $testobj->testarray["dim1"]["dim2"]; // Result = 20 - bad (should
be 30)!
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=17781&edit=1