Are there some special rules to set a variable into a multidimensional array for php? -
ok, i'm stumped here. i'm trying set variable multidimensional associative array, , not understand why not working.
class myclass { private $someproblem = 'data_is_here'; private $access_array = array ('key1a' => array ( 'key2a' => array('key3a' => 'data1','key3b' => 'data4', 'key3c' => $someproblem), 'key2b' => array('key3a' => 'data2','key3b' => 'data5', 'key3c' => $someproblem), 'key2c' => array('key3a' => 'data3','key3b' => 'data6', 'key3c' => $someproblem) ) ...more array values here, same pattern... }
in iteration, get:
parse error: syntax error, unexpected '$someproblem' (t_variable) in myclass.class.php on line 10
i've tried changing $someproblem constant, making static, making public, etc getting error variable appears (error changes, fatal).
appreciate help in advance- especially, please explain why it's not failing @ 'key3a'=>'data1', , why if replace $someproblem 'data_is_here', works.
apart quote problem, cannot want in php. according manual on class properties:
this declaration may include initialization, initialization must constant value--that is, must able evaluated @ compile time , must not depend on run-time info in order evaluated.
so cannot utilize variable assign value class property declare it. need in constructor.
and not utilize $someproblem
, need utilize $this->someproblem
.
php multidimensional-array variable-assignment
No comments:
Post a Comment