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" Quote Link to comment 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]; } Quote Link to comment 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? Quote Link to comment Share on other sites More sharing options...
Chris92 Posted February 20, 2008 Share Posted February 20, 2008 count($array); Quote Link to comment Share on other sites More sharing options...
JSHINER Posted February 20, 2008 Author Share Posted February 20, 2008 Thanks! Quote Link to comment 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!? Quote Link to comment Share on other sites More sharing options...
Chris92 Posted February 20, 2008 Share Posted February 20, 2008 It vannished Quote Link to comment Share on other sites More sharing options...
JSHINER Posted February 20, 2008 Author Share Posted February 20, 2008 Not cool. Quote Link to comment 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.