Guest Posted October 9, 2012 Share Posted October 9, 2012 Hi Everyone, I'm trying to get rid of the 0,1,2 etc ... in-front of my parameters when I display data from my array. Any help here would be appreciated. Thanks everyone! http://whatsmyowncar...week4/while.php (bottom example) $newschannels = array('Local'=>array('ABC6 News','CBS Stations','Local Fox News','NBC News'), 'Regional'=>array('YES Network','NESN'), 'National'=>array('Fox News','CNN','MSNBC'), 'International'=>array('BBC News','France International','Ireland International')); foreach($newschannels as $channels => $data){ echo "$channels".'<br>'; foreach($data as $key => $value){ echo "Region: $key, Channel: $value".'<br>'; } } Link to comment https://forums.phpfreaks.com/topic/269271-multi-arrays-and-using-a-foreach/ Share on other sites More sharing options...
Jessica Posted October 9, 2012 Share Posted October 9, 2012 Remove Region: $key from the echo? Seriously. Link to comment https://forums.phpfreaks.com/topic/269271-multi-arrays-and-using-a-foreach/#findComment-1384021 Share on other sites More sharing options...
matthewtbaker Posted October 10, 2012 Share Posted October 10, 2012 Here you go; $newschannels = array('Local'=>array('ABC6 News','CBS Stations','Local Fox News','NBC News'), 'Regional'=>array('YES Network','NESN'), 'National'=>array('Fox News','CNN','MSNBC'), 'International'=>array('BBC News','France International','Ireland International')); foreach($newschannels as $channels => $data){ echo "$channels".'<br>'; foreach($data as $key => $value){ echo "Channel: $value".'<br>'; } } Simply delete the $key variable from your echo statement. Matt Link to comment https://forums.phpfreaks.com/topic/269271-multi-arrays-and-using-a-foreach/#findComment-1384142 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.