I am trying to access data from a multidimensional array. Array $o
contains arrays of with the key: product_id. The child array 'data' contains key => value pairs
(or at least I think it does). The problems is that when I try to access the data later on: nothing is working.
Question: How can I access this data as expected in a key => value
pair method that works (like foreach($o[$_product_id]['data'] as $_attr => $_value)
)
Original data
$_product_id=1;
$h = array('header1','header2','header3');
$line= array(1,2,3);
$o[$_product_id]['data'] = array_combine($h,array_map('trim', $line));
I var_dumped $o[$_product_id]['data']
and I can see the data is there
$data =
array (
'header1' => 1,
'header2' => 2,
'header3' => 3,
);
Help appreciated
=======================
Loading data original method
$o[$_product_id]['data'] = array_combine($h,array_map('trim', $line));
Loading data alternative method
foreach ($h as $_atr) {
$o[$_product_id]['data'][$_atr] = trim(array_shift($line));
}
Accessing data: not working as expected
foreach($o[$_product_id]['data'] as $_attr => $_value)
echo $_attr;
echo $_value;