OK, I'm still looking for help. It does work like this, but I have just found out the machine this has to be deployed on does not have the latest build - and as such can not make use of the array_flip() function. The owner of the site has no control over the machine.
So, how can I resolve this problem without making use of array_flip(). Please bear in mind that upgrading is not an option
Thanks
WAPMail wrote:
OK, I think I've sorted it, although it seems a little messy; I am sure this can be done more elegantly. If anyone else has a better way, please let me know.
Basically, I have added the following 2 lines, immediately after creating the array:
$sorted = array_flip($entrantpoints);
krsort($sorted);
In all, the script now looks like :
<?php
$entrantpoints = array( "SMITH, John" => 28,
"SMYTHE, Paris" => 10,
"DAVIES, Jenny" => 1,
"JONES, Simon" => 20,
"BONE, Simon" => 0,
"ANSTEYS, Michelle" => 3,
"HART, Darren" => 15,
"DOOR, Joe" => 22,
"WILLIAMS, Andy" => 0,
"STERLING, Penny" => 27
);
$sorted = array_flip($entrantpoints);
krsort($sorted);
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
while (list ($entrant, $points) = each ($sorted)) {
echo "<tr>";
echo "<td>";
echo "$entrant: $points\n ";
echo "</td>";
echo "</tr>";
}
echo "<table>";
?>