ok, so i have information stored in a string in a MySQL database. the string gets returned something like "a,b,c,d|e,f,g,h|i,j,k,l." After retrieving this string i separate it into arrays, first by exploding it using the pipe (|), then the commas, and then echoing it from within a loop.
the way it works now is it lists the data in order of how it exists within the original string, eg:
1.abcd
2.efgh
3.ijkl
what i would like to do is reverse the order in which it reads the string, or in other words, lists the data:
1.ijkl
2.efgh
3.abcd
here's the code:
<?php
if($row['timeSheet'] != ''){
$array = explode('|', rtrim($row['timeSheet'], '|'));
$count = count($array);
foreach($array as $each){
$info = explode(',', $each);
$formatted=date('F d, Y', strtotime($info[0]));
echo'<tr>
<td valign="top" class="bodycopy">' . $formatted . '</td>
<td colspan="2" valign="top" class="bodycopy">' . $info[1] . '</td>
<td valign="top" class="bodycopy">' . ucwords($info[3]) . '</td>
<td valign="top" class="bodycopy">' . $info[2] . '</td>
</tr>';
}
}
?>
i need the $info's to start from the end, not the beginning.