array(4) { [0] => object(Shipping\Model\Shipping)#337 (5)-6ren">
gpt4 book ai didi

php - array_column 不适用于对象数组?

转载 作者:行者123 更新时间:2023-12-02 20:32:47 25 4
gpt4 key购买 nike

这是我当前的数组结构:

array(2) {
["Ground"] => array(4) {
[0] => object(Shipping\Model\Shipping)#337 (5) {
["shipping_id"] => NULL
["min_weight"] => string(4) "0.00"
["max_weight"] => string(4) "5.00"
["shipping_method"] => string(6) "Ground"
["shipping_rate"] => string(4) "8.00"
}
[1] => object(Shipping\Model\Shipping)#385 (5) {
["shipping_id"] => NULL
["min_weight"] => string(4) "6.00"
["max_weight"] => string(5) "10.00"
["shipping_method"] => string(6) "Ground"
["shipping_rate"] => string(5) "12.00"
}
}
["Expedited"] => array(4) {
[0] => object(Shipping\Model\Shipping)#388 (5) {
["shipping_id"] => NULL
["min_weight"] => string(4) "0.00"
["max_weight"] => string(4) "5.00"
["shipping_method"] => string(9) "Expedited"
["shipping_rate"] => string(5) "12.00"
}
}
}

每次我为 max_weight 运行 array_column 时,都会得到一个空数组。我应该将返回的数组用于 max()。有解决方法吗?

最佳答案

v7.0.0: Added the ability for the input parameter to be an array of objects.

来源:https://secure.php.net/manual/en/function.array-column.php

关于php - array_column 不适用于对象数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48178161/

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