I have been using php for a little while and have used a similar loop on my other pages without fail. This loop I can't seem to get it to show the way it needs to. Here is what I am trying to do. I want to take an unserialized array consisting of numbers, sort them, then display them in order, but at the same time display all the info in that correspnding index number. For instance, say I have three rows pulled from the database, number, place, state.
For instance:
$state = @unserialize($row['state']);
contents:
$state[1] = "NY";
$state[2] = "AZ";
$state[3] = "DE";
$place = @unserialize($row['place']);
contents:
$place[1] = "Main Street";
$place[2] = "East Ave";
$place[3] = "South Street";
$number = @unserialize($row['number]);
contents:
$number[1] = "9";
$number[2] = "6";
$number[3] = "2";
Now I want to arrange the values of $number numerically from lowest to highest using sort:
sort($number);
That would bring up $number[1] = 2;
$number[2] = 6;
$number[3] = 9;
that changed all the indexes from 1>3, 2>2, 3>1
Is there a built in php function that would preserve the $place, $state values so that they now correspond to their appropriate value in the arranged $numbers array even though they now have different indices than the numbers values ?
Thanks in advance for any help.