I have an array with images and a date for each. I get the date through the explode array. I want to take this date value and compare it with the previous date value for the previous image. My goal here is to show these dates as headings for sets of images corresponding to each other date.
Here is my code I worked with to try to do this job (sorry for all my slashes):
$p = 0; $a = -1; echo "<table>"; echo "<tr>"; foreach (array_combine($images,$locs) as $image => $loc) { $p++; $a++; $datesort = explode('>',$image); echo "<style>"; echo "input[label=t" . $p . "] {"; echo "display: none;"; echo "}"; echo "input[label=t" . $p . "] + label {"; echo "border: 5px solid #FFFFFF;"; $image = "background: url('http://blah.com/" . $loctb[$p] . "');"; echo $image; echo "height: 61px;"; echo "width: 92px;"; echo "display: inline-block;"; echo "padding: 0 0 0 0px;"; echo "}"; echo "input[label=t" . $p . "]:checked + label {"; echo "border: 5px solid #FF9900;"; echo "background: url('http://blah.com/" . $loctb[$p] . "');"; echo "height: 61px;"; echo "width: 92px;"; echo "display: inline-block;"; echo "padding: 0 0 0 0px;"; echo "}"; echo "</style>"; $lastdate = array(""); $lastdate[$a] = $datesort[1]; echo "<td>"; if ($lastdate[$a] <> $datesort[1]){ echo "<h2>"; echo $datesort[1]; echo "</h2>"; } echo "<input type=\"checkbox\" label=\"t" . $p . "\" id=\"t" . $p . "\" name =\"boxes[]\" value=\"<img src=http://blah.com/" . $loc . "\" />"; echo "<label for=\"t" . $p . "\"></label>"; echo "</div>"; echo "</td>"; if ($p % 2 == 0) { echo "</tr>"; } } echo "</table>";
I tried to save the current date value to another array variable and then compare it with the new value next time through my foreach , but I am doing it wrong: - / ...
I would appreciate any help you can offer. Thanks
source share