如何在PHP中使用关联数组来连接值?

时间:2019-11-27 06:21:55

标签: php arrays foreach associative-array

我正在使用foreach循环,我想在单独的数组中显示相关值,我的当前结果是这样:

{"response": {
    "message":"",
    "statistics": [
    {
        "player_name": "J. Bruun Larsen",
        "goals_total": "2"
    },
    {
        "player_name": "Ö. Toprak",
        "goals_total": "1"
    },

    {
        "player_name": "M. Hitz",
        "goals_assists": "0"
    },
    {
        "player_name": "M. Hitz",
        "goals_assists": "0"
    },

    {
        "player_name": "Ö. Toprak",
        "cards_yellow": "6"
    },
    {
        "player_name": "Ö. Toprak",
        "cards_yellow": "5"
    },

    {
        "player_name": "Ö. Toprak",
        "cards_red": "0"
    },
    {
        "player_name": "Ö. Toprak",
        "cards_red": "0"
    },
  ]}
}

我想在其自己的数组中显示每个相关值。 示例:goals_total数组中的goals_total值,与此类似,goal_assist数组中的goals_assist值。 我在php中使用foreach循环。

1 个答案:

答案 0 :(得分:0)

您可以使用称为link的PHP核心函数,该函数可以指示数组中存在的键的返回值。     

Method Illuminate\Routing\ResponseFactory::withCookie does not exist.