有两个数组,长度相同,去重后,如何还能保持一致。
比如
$t1=Array ( [0] => 南昌 [1] => 南昌 [2] => 赣州 [3] => 九江 [4] =>赣州 [5] => 九江)
$t2=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 )
现在$t1和$t2 都是相同长度。而且他们还存在一个对应关系。那就是t1[0]和t2[0]。。t1[1]和t2[1].....t1[i]和t2[i]是相关联的,
我现在想实现不重复t1里面的value不重复。然后在和t2对应,如果有重复的,就保留t2里面时间最小的那个。
并且新的数组t22里面的的value是从小到大的顺序。
得到的结果我想是,
$t11=Array ( [0] => 九江 [1] => 赣州 [2] => 南昌 )
$t22=Array ( [0] => 2013-09-12 08:40:03 [1] => 2013-09-21 17:48:23 [2] => 2013-09-23 12:48:42 )
或者把t1,t2合并成一个二维数组更方便实现也可以,感谢。
回复讨论(解决方案)
$t1 = Array ( 0 => '南昌', 1 => '南昌', 2 => '赣州', 3 => '九江', 4 => '赣州', 5 => '九江'); $t2 = 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' );foreach(array_map(null, $t1, $t2) as $r) { if(! isset($t[$r[0]])) $t[$r[0]] = $r[1]; else $t[$r[0]] = min($t[$r[0]], $r[1]);}asort($t);$t11 = array_keys($t);$t22 = array_values($t);print_r($t11);print_r($t22);
(
[0] => 九江
[1] => 赣州
[2] => 南昌
)
Array
(
[0] => 2013-09-12 08:40:03
[1] => 2013-09-21 17:48:23
[2] => 2013-09-23 12:48:42
)

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

PHP logging is essential for monitoring and debugging web applications, as well as capturing critical events, errors, and runtime behavior. It provides valuable insights into system performance, helps identify issues, and supports faster troubleshoot

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Alipay PHP...

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.
