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

标签 php arrays multidimensional-array array-column

这是我当前的数组结构:

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/

相关文章:

c - 使用 C 中的常量列表初始化多维数组的一部分

PHP二维数组转HTML输入值

c++ - 在 C++ 中将值插入多维 vector

javascript - 尝试制作一个按钮,仅显示设置了值或变量的项目

php - 添加源以构建 php 扩展

arrays - 如何使用jq检查数组中是否存在元素

c++ - 在 C++ 中顺序读取文本文件

java - 用 2D 数组表示 8x8 维度的问题

php - 如何将变量从表单传递到 javascript 弹出表单?

php - PHP的null值不等于MySQL的null值吗?