3
我有2個關聯數組:排序和合並關聯數組(PHP)
[0] => Array (
[time] => 09:00:00
[name] => To do something 1
)
[1] => Array (
[time] => 09:30:00
[name] => To do something 2
)
[2] => Array (
[time] => 10:00:00
[name] => To do something 3
)
和
[0] => Array (
[time] => 09:00:00
)
[1] => Array (
[time] => 09:15:00
)
[2] => Array (
[time] => 09:30:00
)
[3] => Array (
[time] => 09:45:00
)
[4] => Array (
[time] => 10:00:00
)
需要做另一個關聯數組:
- 如果字段[時間]在第二個數組中等於第一個數組中的字段[時間],然後添加[name];
- 如果第二個數組中的field [time]不等於第一個數組中的field [time],則添加空[name]。
應該是這樣的:
[0] => Array (
[time] => 09:00:00
[name] => To do something 1
)
[1] => Array (
[time] => 09:15:00
[name] =>
)
[2] => Array (
[time] => 09:30:00
[name] => To do something 2
)
[3] => Array (
[time] => 09:45:00
[name] =>
)
[4] => Array (
[time] => 10:00:00
[name] => To do something 3
)
遺憾的是它不工作,但只顯示一個數組中的最後一條記錄[名]和陣列秀等元素與空[名]鍵,但我理解你的想法。謝謝。 –