Is there a way to sort two different arrays based upon the sorting of one?
for example:
<?php
$fruits = array("lemon", "orange", "banana", "apple");
$colors = array("yellow", "orange", "yellow", "red");
sort($fruits);
?>
So that the result would be like:
fruits[0] = apple
fruits[1] = banana
fruits[2] = lemon
fruits[3] = orange
colors[0] = red
colors[1] = yellow
colors[2] = yellow
colors[3] = orange
I certainly realize that sort() would only sort fruits alphabetically and not affect colors in the slightest but the result is what I am looking for. I have been searching the array functions for the proper sort function... but have not found it and just thought I would ask in hopes someone could tell me easier and faster.
Here is the idea more completely... basically I have a table and want to make it user sortable and rather than making new MySQL queries each time I thought to just store the initial results in arrays and somehow link the keys of each array so that they all sort the same through the sorting of one.