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; } Quote 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? Quote 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 Quote 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. Quote 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?? Quote 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? Quote Link to comment https://forums.phpfreaks.com/topic/161685-putting-data-into-array/#findComment-853131 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.