How to get the contents of a specified time period and correspond to other arrays.
$t 1=array ([0] = = Nanchang [1] = Nanchang [2] = Ganzhou [3] = Jiujiang [4] = Ganzhou [5] = Jiujiang)
$t 2=array ([0] = 2013-09-24 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)
For example, I have two of the above arrays. $t 1 "0" and $t2 "0" .... $t 1 "i" and $t2 "I" are relevant, $t 1 "0" and $t2 "0" represent ===== Nanchang, excellent.
For example, I now want to take the data from 2013-09-23 10:48:33 to 2013-09-27 11:28:13 in the $t2 array to form a new array, $t 22.
And then put $t1 inside corresponding also match, is T2 inside corresponding key delete, T1 inside also the corresponding key delete.
The result I want to get is.
$t 22=array ([0] = 2013-09-24 17:48:33 [1] = 2013-09-23 12:48:42 [2] = 2013-09-27 11:28:13)
$t 11=array ([0] = = Nanchang [1] = Nanchang [2] = Jiujiang)
Get these two new arrays: The process of seeking.
Share to:
------Solution--------------------
{
$start = ' 2013-09-23 10:48:33 ';
$end = ' 2013-09-27 11:28:13 ';
if ($v >= $start && $v <= $end)
{
return true;
}
return false;
}
$t 1=array (' 0 ' = ' nanchang ', ' 1 ' = ' Nanchang ', ' 2 ' = ' Ganzhou ', ' 3 ' = ' Jiujiang ', ' 4 ' = ' Ganzhou ', ' 5 ' = ' Jiujiang ');
$t 2=array (' 0 ' = ' 2013-09-24 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 ');
$t =array_filter ($t 2, "myFunction");
foreach (Array_keys ($t) as $k) $t 11[]= $t 1[$k];
$t 22=array_values ($t);
Print_r ($t 22);
Print_r ($t 11);