timmah1 Posted January 29, 2009 Share Posted January 29, 2009 I grab information from the database that matches the current month, then I put the days into an array like so $days[] = date("d", strtotime($charts['posted'])); Then I implode them to make put marks on a graph $day = implode(',', $days); Works great. But what I want to know is, how can I find out what the first day in the database is? Right now, the database has the days 11 through 29, but I need the code to be able to only show the first number, which would be 11 in this case, then I'll do some math stuff to fill in the gaps on the graph. So basically what I need to know is, with the following code $days[] = date("d", strtotime($charts['posted'])); $day = implode(',', $days); How do I find out the first number? Thanks in advance Link to comment https://forums.phpfreaks.com/topic/143039-solved-not-sure-how-to-title-this/ Share on other sites More sharing options...
gaza165 Posted January 29, 2009 Share Posted January 29, 2009 so really what you are looking for is the lowest number (day) in your array of dates?? Link to comment https://forums.phpfreaks.com/topic/143039-solved-not-sure-how-to-title-this/#findComment-750065 Share on other sites More sharing options...
timmah1 Posted January 29, 2009 Author Share Posted January 29, 2009 Correct. I need the code to stay the way it is, but I want to be able to find the lowest number, so I can do some other things with that, and I'm not sure who to do it Link to comment https://forums.phpfreaks.com/topic/143039-solved-not-sure-how-to-title-this/#findComment-750066 Share on other sites More sharing options...
xangelo Posted January 29, 2009 Share Posted January 29, 2009 The easiest way would be to do this: $days[] = date("d", strtotime($charts['posted'])); sort($days); $day = implode(',', $days); sort() Link to comment https://forums.phpfreaks.com/topic/143039-solved-not-sure-how-to-title-this/#findComment-750067 Share on other sites More sharing options...
gaza165 Posted January 29, 2009 Share Posted January 29, 2009 why dont you use the min() to get the lowest number of the days $days[] = date("d", strtotime($charts['posted'])); $first_date = min($days); $day = implode(',', $days); Link to comment https://forums.phpfreaks.com/topic/143039-solved-not-sure-how-to-title-this/#findComment-750079 Share on other sites More sharing options...
gevans Posted January 29, 2009 Share Posted January 29, 2009 You want to look at sort() <?php $days[] = date("d", strtotime($charts['posted'])); sort($days, SORT_NUMERIC); $day = implode(',', $days); Link to comment https://forums.phpfreaks.com/topic/143039-solved-not-sure-how-to-title-this/#findComment-750081 Share on other sites More sharing options...
timmah1 Posted January 29, 2009 Author Share Posted January 29, 2009 Exactly gaza165! Thank you so much!! Link to comment https://forums.phpfreaks.com/topic/143039-solved-not-sure-how-to-title-this/#findComment-750083 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.