SeanHarding Posted October 31, 2008 Share Posted October 31, 2008 I have an array of time() dates. Im also grouping them by Month and by Year also displaying the number of times that month is repeated. Here is my code: $doomed = array(); $doomed[] = '1225294183'; $doomed[] = '1224689938'; $doomed[] = '1170862952'; foreach ($doomed as $k=>$v) { $doom[]=date('F y',$v); } $result=array_count_values($doom); foreach($result as $key=>$val) { echo '<a href="http://www.web_site/Blog/archive.php?x='. $key .'">'. $key .' ('. $val .')</a><br>'; } The result is a hyperlinked date year and amount of posts. October 08 (2) February 07 (1) Is it possible for me to send the original timestamps for each month to another page via the URL? e.g. http://www.website.co.uk/Blog/archive.php?x=' array of times ' Quote Link to comment Share on other sites More sharing options...
zenag Posted October 31, 2008 Share Posted October 31, 2008 $doomed = array(); $doomed[] = '1225294183'; $doomed[] = '1224689938'; $doomed[] = '1170862952'; $serialz=serialize($doomed); $encode=urlencode($serialz); ?> <a href="http://www.web_site/Blog/archive.php?x=<?php echo $encode ?>">pass</a> in archive.php if($_GET) { $arr = unserialize(urldecode(stripslashes($_GET['x']))); print_r($arr); } Quote Link to comment Share on other sites More sharing options...
SeanHarding Posted October 31, 2008 Author Share Posted October 31, 2008 Thanks again Zenag, but I only need October 08's variables in the array. The bigger picture is... i'm selecting all the time() from my database and displaying them, i'm also grouping the time() by month and year.... Im linking these to another page so I can search my database and display results from only these time() Quote Link to comment Share on other sites More sharing options...
SeanHarding Posted October 31, 2008 Author Share Posted October 31, 2008 Is it possible to create a multidimensional array to accomplish this? Quote Link to comment Share on other sites More sharing options...
samshel Posted October 31, 2008 Share Posted October 31, 2008 $doomed = array(); $doomed[] = '1225294183'; $doomed[] = '1224689938'; $doomed[] = '1170862952'; $doom = array(); foreach ($doomed as $k=>$v) { if(date('Y') == date('Y', $v) && date('m') == date('m', $v)) { $doom[]=date('F y',$v); } } $serialz=serialize($doom); $encode=urlencode($serialz); ?> <a href="http://www.web_site/Blog/archive.php?x=<?php echo $encode ?>">pass</a> this will send all time stamps from current month only..[Oct 2008] Quote Link to comment Share on other sites More sharing options...
SeanHarding Posted October 31, 2008 Author Share Posted October 31, 2008 thanks for your post but... I need to list the months in my array and also link them. The results needed are the following: <a href="Blog?x=' array of October 08's numbers '">October 08 (2)</a> <a href="Blog?x=' array of February 07's numbers '">Febuary 07 (1)</a> Quote Link to comment Share on other sites More sharing options...
samshel Posted October 31, 2008 Share Posted October 31, 2008 $doomed = array(); $doomed[] = '1225294183'; $doomed[] = '1224689938'; $doomed[] = '1170862952'; $doom = array(); foreach ($doomed as $k=>$v) { $doom[date('F y',$v)][] = $v; } foreach ($doom as $k=>$v) { $serialz=serialize($v); $encode=urlencode($serialz); ?> <a href="http://www.web_site/Blog/archive.php?x=<?php echo $encode ?>"><?php echo $k ?></a> <?php } ?> Please note that the dates are passed encoded serialized...so on the page you are sending them they have to be decoded and unserialized, if you dont have control on that page, you can send the comma seperated like this $doomed = array(); $doomed[] = '1225294183'; $doomed[] = '1224689938'; $doomed[] = '1170862952'; $doom = array(); foreach ($doomed as $k=>$v) { $doom[date('F y',$v)][] = $v; } foreach ($doom as $k=>$v) { $strDates = implode(",", $v); ?> <a href="http://www.web_site/Blog/archive.php?x=<?php echo $strDates ?>"><?php echo $k ?></a> <?php } ?> Quote Link to comment Share on other sites More sharing options...
SeanHarding Posted October 31, 2008 Author Share Posted October 31, 2008 Thats amazingly perfect thanks Samshel I updated the last bit to make it more 'me' friendly lol foreach ($doom as $k=>$v) { $serialz=serialize($v); $encode=urlencode($serialz); echo "<a href=\"http://www.web_site/Blog/archive.php?x=$encode\">$k</a><br />"; } 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.