Assume you have an array called $dates which are in the format DD/MM/YYYY. The a
ID: 3843633 • Letter: A
Question
Assume you have an array called $dates which are in the format DD/MM/YYYY. The array is indexed by keys. For example the array might look something like: $days = array("key1" => "05/16/2010", "some_date" => "04/02/1990", "four" => "05/06/2007"); Write a snippet of PHP that creates the following XHTML table out of the data provided in the $days array Each row of the table should correspond to an array entry. The first cell of each row has the date from the array and the second cell has the corresponding weekday. For our example the table would look like the one below. Of course the actual table depends on the $days array given.Explanation / Answer
<?php
$dates = array("key1"=>"05/16/2010","some_date"=>"04/02/1990","four"=>"05/06/2007");
$len = count($dates);
for($i=0;$i<$len;$i++)
{
$days[$i]=date('l', $dates[$i]);
echo $days[$i];
}
echo"<table>";
for($i=0;$i<$len;$i++)
{
echo" <tr> <td>";
echo $dates[$i] ;
echo "</td><td>";
echo $days[$i] ;
echo "</td></tr>";
}
?>
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.