slaterino Posted June 9, 2011 Share Posted June 9, 2011 Hi, I'm so very close to getting the information I need but just have one final hurdle. I have created an array called $data but just need some help getting the data back out of the array. This is my loop where I am trying to output the data: foreach($data as $date => $v) { echo date('D', strtotime($date)) . '<br />'; echo date('d', strtotime($date)) . '<br />---------<br />'; foreach($v as $event) { echo $event; echo "<br />"; } echo '<br />'; } The first loop works fine where I am outputting the dates, but then the $event value is incorrect. At the moment I am simply getting 'Array' for the $event value. However I want to be able to get two values, the ID and the date that are in the array. How do I get this data out of the array? I have been looking at the array() page at php.com for hours trying to work this one out but still can't get there! Here's the result of "print_r($data,true)": Array ( [06/09/2011] => Array ( [0] => Array ( [13] => 06/09/2011 ) [1] => Array ( [15] => 06/08/2011 - 06/10/2011 ) ) [06/10/2011] => Array ( [0] => Array ( [15] => 06/08/2011 - 06/10/2011 ) ) [06/11/2011] => [06/12/2011] => [06/13/2011] => Array ( [0] => Array ( [6] => 06/13/2011 ) ) [06/14/2011] => [06/15/2011] => ) Quote Link to comment https://forums.phpfreaks.com/topic/238896-echo-variables-in-array/ Share on other sites More sharing options...
fugix Posted June 9, 2011 Share Posted June 9, 2011 looks like you might even need to go one level deeper into your multi dimensional array..try foreach($data as $date => $v) { echo date('D', strtotime($date)) . '<br />'; echo date('d', strtotime($date)) . '<br />---------<br />'; foreach($v as $event) { foreach($event as $key=>$val) { //do stuff } } echo '<br />'; } however, im sure that there is a better solution Quote Link to comment https://forums.phpfreaks.com/topic/238896-echo-variables-in-array/#findComment-1227523 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.