I have this array similar to this:
$suppliers = array(
'Utility Warehouse' => array('Gas' => array(0,0), 'Electricty' => array(0,0)),
'British Gas' => array('Gas' => array(93,124), 'Electricty' => array(93,124)),
'Eon' => array('Gas' => array(93,124), 'Electricty' => array(93,124))
);
How can display the information as follows
Utility Warehouse
Gas: 0-0 Electricity 0-0
British Gas
Gas: 93-134 Electricity: 93-134
Eon
Gas: 93-124 Electricity: 93-134
You can see how the displayed data corresponds to the data in the array. I've tried this:
foreach($suppliers as $a){
echo $a[0];
}
But this does nothing. CONFUSED!
UPDATE Need to say thanks guys, and I apologise for my lack of knowledge. I have never used nested arrays before, and I did search around for a solution before I posted here.
echo
language construct only takes strings as an argument, tho it will attempt to convert things (integers, etc.) to strings. Arrays don't have an automatic method to convert to strings so you can'techo
an whole array. Check out the examples here. – sequoia mcdowell Oct 18 '11 at 14:47