$result = eval( 'return $array'.$test.';' );
Um...
echo $array[$dim1][$dim2][$dim3][$dim4];
eval == evil. I can't think of a single legimiate reason why you'd want/need to make a string "[$dim1]...." first, and if you have to I'd suspect that something is very wrong with the way you are writing your script.
Feel free to prove me wrong, though :)
John
Robert Cummings writes:
On Sat, 2003-11-29 at 19:47, Robert Cummings wrote:
On Sat, 2003-11-29 at 19:29, sophie@sitadelle.com wrote:
I'm soory but your code doesn't make me understand what you want to do...
Be more precise, it will help you to get some help
I have this code, I would like, if this could be done
<?
$array['dim1']['dim2']['dim3'][3] = "value";
$dim1 = 'dim1';
$dim2 = 'dim2';
$dim3 = 'dim3';
$dim4 = 3;
$test = "[$dim1][$dim2][$dim3][$dim4]";
$result = "$array$test";
echo $result;
?>
The output is : Array[dim1][dim2][dim3][3]
I need that the output was: value
Ignore my last answer, I read your problem wrong. Answer below:
<?
$array['dim1']['dim2']['dim3'][3] = "value";
$dim1 = 'dim1';
$dim2 = 'dim2';
$dim3 = 'dim3';
$dim4 = 3;
$test = '[$dim1][$dim2][$dim3][$dim4]';
$result = eval( 'return $array'.$test.';' );
echo $result;
?>
HTH,
Rob.
-- .------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
-- PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php