JSHINER Posted February 20, 2008 Share Posted February 20, 2008 foreach ($page['people'] as $z) { $date = date('m-d-y', strtotime($z['date'])); $now = date('m-d-y'); } How can I create something that counts how many $date = $now - so if there were 50 dates, and seven of them = $now I could display "7 today" Link to comment https://forums.phpfreaks.com/topic/92120-question-about-count/ Share on other sites More sharing options...
Chris92 Posted February 20, 2008 Share Posted February 20, 2008 Put an if inside your loop, then keep adding to a variable and set it into an array: $i = 0; $array = array(); foreach ($page['people'] as $z) { $date = date('m-d-y', strtotime($z['date'])); $now = date('m-d-y'); if($date == $now) { $array[] = "Whatever you want to store here"; } } for($i=0; $i <= 7; $i++) { echo $array[$i]; } Link to comment https://forums.phpfreaks.com/topic/92120-question-about-count/#findComment-471789 Share on other sites More sharing options...
JSHINER Posted February 20, 2008 Author Share Posted February 20, 2008 How now how can I count how many there are in that array? Link to comment https://forums.phpfreaks.com/topic/92120-question-about-count/#findComment-471793 Share on other sites More sharing options...
Chris92 Posted February 20, 2008 Share Posted February 20, 2008 count($array); Link to comment https://forums.phpfreaks.com/topic/92120-question-about-count/#findComment-471801 Share on other sites More sharing options...
JSHINER Posted February 20, 2008 Author Share Posted February 20, 2008 Thanks! Link to comment https://forums.phpfreaks.com/topic/92120-question-about-count/#findComment-471803 Share on other sites More sharing options...
JSHINER Posted February 20, 2008 Author Share Posted February 20, 2008 Where did the "Topic Solved" option go!? Link to comment https://forums.phpfreaks.com/topic/92120-question-about-count/#findComment-471805 Share on other sites More sharing options...
Chris92 Posted February 20, 2008 Share Posted February 20, 2008 It vannished Link to comment https://forums.phpfreaks.com/topic/92120-question-about-count/#findComment-471809 Share on other sites More sharing options...
JSHINER Posted February 20, 2008 Author Share Posted February 20, 2008 Not cool. Link to comment https://forums.phpfreaks.com/topic/92120-question-about-count/#findComment-471827 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.