How to get the contents of a specified time period and correspond to other arrays

Source: Internet
Author: User
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);
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.