paruby Posted March 31, 2008 Share Posted March 31, 2008 I know how to work w/ arrays when they are passed from say a POST, but can't seem to create one on my own... I have 2 sets of variables. I have a name and date, and want to print them. I have basically: $Name1 = "John"; $Date1 = "200802"; // Formatted as CCYYMM $Name2 = "Mark"; $Date2 = "200803"; I want print them as: <a href=$Date1.php>$Name1 - $Date1</a> <br> <a href=$Date2.php>$Name2 - $Date2</a> <br> But I am unsure how I build the array in the first place. My second question is, can I convert the date variable to the month name, ie "February 2008", "March 2008", in the link after the name variable? Thanx! Pete Link to comment https://forums.phpfreaks.com/topic/98757-muliti-dimensional-array-question-w-date/ Share on other sites More sharing options...
Barand Posted March 31, 2008 Share Posted March 31, 2008 <?php $Name1 = "John"; $Date1 = "200802"; // Formatted as CCYYMM $Name2 = "Mark"; $Date2 = "200803"; $data = array( array ($Name1, $Date1), array ($Name2, $Date2), ); foreach ($data as $item) { list($nm, $dt) = $item; $display = date('F Y', strtotime($dt.'01')); echo "<a href='$dt.php'>$nm - $display</a><br/>"; } ?> Link to comment https://forums.phpfreaks.com/topic/98757-muliti-dimensional-array-question-w-date/#findComment-505405 Share on other sites More sharing options...
paruby Posted March 31, 2008 Author Share Posted March 31, 2008 Thanx Barand! As usual, I was over complicating it! Pete Link to comment https://forums.phpfreaks.com/topic/98757-muliti-dimensional-array-question-w-date/#findComment-505624 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.