Question

I see that it is possible to calculate a value inside an associative array like this:

$testarray = array(
"x"=>2,
"y"=>5,
"z"=>(5*2);

 print_r($testarray); //Array ( [x] => 2 [y] => 5 [z] => 10 )

Is it possible to do it in a manner like this:

$testarray = array(
"x"=>2,
"y"=>5,
"z"=>x*y);
Était-ce utile?

La solution

No. You cannot access an array's elements before the array is defined.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top