gaza165 Posted June 10, 2009 Share Posted June 10, 2009 Im trying to place all my emails into in array so i reverse the array to display the emails in the order i would like. can someone tell me where i am going wrong with this code?? for($i = 1; $i < $numEmails+1; $i++) { $mailHeader = @imap_headerinfo($conn, $i); $data[] = array("from"=> $mailHeader->fromaddress, "subject"=> $mailHeader->subject, "date" => $mailHeader->date); } foreach ($data as $value) { echo $value[0]->from; } Link to comment https://forums.phpfreaks.com/topic/161685-putting-data-into-array/ Share on other sites More sharing options...
Maq Posted June 10, 2009 Share Posted June 10, 2009 You know there is a native function - array_reverse? Link to comment https://forums.phpfreaks.com/topic/161685-putting-data-into-array/#findComment-853122 Share on other sites More sharing options...
gaza165 Posted June 10, 2009 Author Share Posted June 10, 2009 Yeah i know but im not 100% clear on how to display my array using the for each Link to comment https://forums.phpfreaks.com/topic/161685-putting-data-into-array/#findComment-853123 Share on other sites More sharing options...
Maq Posted June 10, 2009 Share Posted June 10, 2009 Have you read through the manual - foreach. You will need two of them because you have a 2d array. Link to comment https://forums.phpfreaks.com/topic/161685-putting-data-into-array/#findComment-853125 Share on other sites More sharing options...
gaza165 Posted June 10, 2009 Author Share Posted June 10, 2009 foreach($data as $uid=>$values){ foreach($values as $newlist=>$value){ echo $value; } } does that look right?? Link to comment https://forums.phpfreaks.com/topic/161685-putting-data-into-array/#findComment-853128 Share on other sites More sharing options...
Maq Posted June 10, 2009 Share Posted June 10, 2009 foreach($data as $uid=>$values){ foreach($values as $newlist=>$value){ echo $value; } } does that look right?? Why don't you try it first? Link to comment https://forums.phpfreaks.com/topic/161685-putting-data-into-array/#findComment-853131 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.