DETAILS
I have a separate problem that I am investigating that seems to be related to the way I am accessing arrays. Hence this possibly odd question.
I have the following array
$response['custom_validation']['agreetotos0'] ='zero';
$response['custom_validation']['agreetotos1'] ='one';
I would like to use the current subscription level to determine the agreetotos name.
For the moment let's assume that $subscriptionlevel =1;
That means the value I am trying to retrieve = $response['custom_validation']['agreetotos1'];
I know I can access this value by using $response['custom_validation']['agreetotos'.$subscriptionlevel];
or I can use variable variables to access the array with the following
$response['custom_validation']['agreetotos'.${'subscriptionlevel'}];
QUESTION
Are there any other ways?
If yes, what are the advantages/drawbacks of using them?
EDIT
I haven't properly explained what I am trying to achieve. I'm looking for syntax equivalent to $response['custom_validation']['agreetotos1']
For example, $response['custom_validation']['agreetotos'][1]
is not equal to $response['custom_validation']['agreetotos1']
whereas
$response['custom_validation']['agreetotos'.$subscriptionlevel]
is the same as $response['custom_validation']['agreetotos1']
.
Sorry for any confusion.
One simple way to do this is..
$response['custom_validation']['agreetotos'][0] ='zero';
$response['custom_validation']['agreetotos'][1] ='one';
And you can access this as..
$response['custom_validation']['agreetotos'][$subscriptionlevel];