Hi,
I'm trying to build an index into a multi dimensional associative
array. I may not know how many dimensions there are so i want to pass
the array indexes as a variable.
$arrayToAccess = array( array('Data'=>a rray('id'=>1,
'title'=>'Manag er')),
array('Data'=>a rray('id'=>1,
'title'='Clerk' )) );
$index = "['Data']['title']";
// or $index=''; if this is a single dim array ie $arrayToAccess =
array('Manager' , 'Clerk');
foreach ( $arrayToAccess as $data {
$foundTitle = ${data.$index};
// do something to found title
}
Is there a way to do this in php without have to build a looping
structure?
I'm trying to build an index into a multi dimensional associative
array. I may not know how many dimensions there are so i want to pass
the array indexes as a variable.
$arrayToAccess = array( array('Data'=>a rray('id'=>1,
'title'=>'Manag er')),
array('Data'=>a rray('id'=>1,
'title'='Clerk' )) );
$index = "['Data']['title']";
// or $index=''; if this is a single dim array ie $arrayToAccess =
array('Manager' , 'Clerk');
foreach ( $arrayToAccess as $data {
$foundTitle = ${data.$index};
// do something to found title
}
Is there a way to do this in php without have to build a looping
structure?
Comment