gpt4 book ai didi

php - 如何避免 PHP 数组中的重复值

转载 作者:行者123 更新时间:2023-11-30 21:54:00 24 4
gpt4 key购买 nike

Array
(
[0] => Array
(
[time_from] => 06:00
[time] => 06:00-07:00
[booking_date_from] => 2017-09-19
[booking_date_to] => 2017-09-19
[court_price] => 100
[pricetype] => hour
)

[1] => Array
(
[time_from] => 06:00
[time] => 06:00-08:00
[booking_date_from] => 2017-09-19
[booking_date_to] => 2017-09-19
[court_price] => 200
[pricetype] => hour
)

[2] => Array
(
[time_from] => 07:00
[time] => 07:00-09:00
[booking_date_from] => 2017-09-19
[booking_date_to] => 2017-09-19
[court_price] => 200
[pricetype] => hour
)

[3] => Array
(
[time_from] => 08:00
[time] => 08:00-09:00
[booking_date_from] => 2017-09-20
[booking_date_to] => 2017-09-20
[court_price] => 100
[pricetype] => hour
)

[4] => Array
(
[time_from] => 11:00
[time] => 11:00-13:00
[booking_date_from] => 2017-09-19
[booking_date_to] => 2017-09-19
[court_price] => 200
[pricetype] => hour
)

)

我的数组是这样的我只是想避免重复的日期重复值我想这样放

Array
(
[0] => Array
(

[time] => 11:00-13:00
[booking_date_from] => 2017-09-19
[booking_date_to] => 2017-09-19
[court_price] => 100
[pricetype] => hour
)

[1] => Array
(
[time_from] => 08:00
[time] => 08:00-09:00
[booking_date_from] => 2017-09-20
[booking_date_to] => 2017-09-20
[court_price] => 100
[pricetype] => hour
)
)

我应该怎么做才能得到这样的输出。

最佳答案

您可以尝试使用 array_unique() 函数 here .有了这个,您可以使用 foreach 函数逐一读取所有列表,并从所有数组中获取一个参数,并使用它来匹配 array_unique()。试一试,如果不行请投反对票,我会提供更多解决方案。

关于php - 如何避免 PHP 数组中的重复值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46013701/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com