【发布时间】:2018-03-02 00:21:02
【问题描述】:
我有以下数组,我只需要一种方法来仅选择第 mnth 值相同的数组。例如,所有第 mnth 值 => 7 的数组。
Array
(
[0] => Array
(
[desc] => rates
[mnth] => 7
[cost] => 8978
)
[1] => Array
(
[desc] => insurance
[mnth] => 8
[cost] => 7680
)
[2] => Array
(
[desc] => water
[mnth] => 7
[cost] => 7800
)
)
【问题讨论】:
-
这听起来是一个很大的挑战,你能告诉我们你到目前为止尝试过的代码吗?
-
根据您的示例输入和迄今为止的最佳编码尝试,向我们展示您的确切预期输出。我敢打赌我的午餐你在这里问了一个重复的问题。您是否在 StackOverflow 上搜索过现有的解决方案?
-
使用循环和 if 语句
-
echo $array[0]['mnth'];
-
@westnblue 不将问题详细信息添加为 cmets。编辑您的问题并使其完整。