There are two arrays, the same length, and how to remain consistent after the weight is gone.
Like what
$t 1=array ([0] = = Nanchang [1] = Nanchang [2] = Ganzhou [3] = Jiujiang [4] = Ganzhou [5] = Jiujiang)
$t 2=array ([0] = 2013-09-23 17:48:33 [1] = 2013-09-23 12:48:42 [2] = 2013-09-21 17:48:23 [3] = 2013-09-12 08:40:03 [4] = 2013-09-23 10:28:22 [5] = 2013-09-27 11:28:13)
Now $T1 and $t2 are all the same length. And they also have a correspondence relationship. That's t1[0] and t2[0]. T1[1] and T2[1].....t1[i] and T2[i] are connected,
I now want to realize that the value within the T1 is not duplicated. Then, in correspondence with the T2, if there are duplicates, keep the T2 inside the smallest time.
And the value inside the new array t22 is the order from small to large.
Got the result I think is that
$t 11=array ([0] = Jiujiang [1] = Ganzhou [2] = Nanchang)
$t 22=array ([0] = 2013-09-12 08:40:03 [1] = 2013-09-21 17:48:23 [2] = 2013-09-23 12:48:42)
or merging T1,t2 into a two-dimensional array is more convenient to implement, thank you.
------Solution--------------------
$t 2 = Array (0 = ' 2013-09-23 17:48:33 ', 1 = ' 2013-09-23 12:48:42 ', 2 = ' 2013-09-21 17:48:23 ', 3 = ' 2013-0 9-12 08:40:03 ', 4 = ' 2013-09-23 10:28:22 ', 5 = ' 2013-09-27 11:28:13 ');
foreach (Array_map (null, $t 1, $t 2) as $r) {
if (! isset ($t [$r [0]]) $t [$r [0]] = $r [1];
else $t [$r [0]] = min ($t [$r [0]], $r [1]);
}
Asort ($t);
$t one = Array_keys ($t);
$t = Array_values ($t);
Print_r ($t 11);
Print_r ($t 22);
Array
(
[0] = Jiujiang
[1] = Ganzhou
[2] = Nanchang
)
Array
(
[0] = 2013-09-12 08:40:03
[1] = 2013-09-21 17:48:23
[2] = 2013-09-23 12:48:42
)