My problem is i have a page that displays files for download, and i need to make it so the user can select how they want to sort the downloads. One of the options is to sort them by the ones with the most hits appearing at the top and the lowest hits appearing at the bottom. I have written some code for it but it doesnt work because i am stuck with a problem, i will try and make it as clear as possible:
$table = array("1","8",6","9");
// So element 2 of $table is 8, and element 2 of $hits is 3, so table 8 has 3 hits, so i can use it when getting the file from the database.
$hits = array("7","3","4","5");
rsort($hits); // Sort $hits in order from lowest to highest, in this case 3457
$hits = array_reverse($hits); // Reverse $hits so now it is from highest to lowest, in this case 7543
But now it has scrambled things, because $hits is fine but it has been reversed, so meanwile element 2 of $table is 8 and element 2 of $hits is 5, witch is wrong, table 8 actully has the file of hits 3, but because things have been reversed in order to display highest to lowest it changes the correspondance between the 2 arrays elements. Understand? Please help... i need a simple as possible example or solution to this problem. Thanks