-1

I have the following JSON array i like to get datas

{
  "data": {
    "restriction_reason": {
      "not_verified": true,
      "using_vpn": false,
      "banned_until": "2020-05-04T17:01:30.000Z",
      "reason": "string"
    },
    "surveys": [
      {
        "id": "string",
        "type": "survey",
        "click_url": "https://api.aa.comc",
        "cpi": "1.2",
        "value": "120",
        "loi": 5.3,
        "country": "US",
        "language": "en",
        "rating": 4,
        "category": {
          "name": "Automotive",
          "icon_name": "string",
          "icon_url": "string",
          "name_internal": "automotive"
        },
        "tags": [
          "pii"
        ],
       
      },{
        "id": "string",
        "type": "survey",
        "click_url": "https://api.aba.comc",
        "cpi": "1.2",
        "value": "1220",
        "loi": 5.3,
        "country": "US",
        "language": "en",
        "rating": 4,
        "category": {
          "name": "Automotive",
          "icon_name": "string",
          "icon_url": "string",
          "name_internal": "automotive"
        },
        "tags": [
          "pii"
        ],
        
      },
    ]
  }
}

I get this response from Curl I like to extract somes items and add to another offers arrow

i need Survey id , survey value , survey click_url and catégory name

exemple :

**

$offers[] = array('survey_id' => $get_data["id"],
          "survey_url" => $get_data["click_url"],
          "survey_value" =>$get_data["value"]);

**

AFTER IF I CREATE offers[] i will encode and merge it with offers2[] (Another json) to get final json arrow

Franklin CI
  • 159
  • 1
  • 9
  • 2
    Read [How to extract and access data from JSON with PHP?](https://stackoverflow.com/questions/29308898/how-to-extract-and-access-data-from-json-with-php) – ADyson Aug 22 '23 at 13:04
  • `USING FOREACH LOOP`...1) you don't need to SHOUT. 2) where are you stuck with using a loop? Decode the JSON, and then loop through the array under the "surveys" property, just like any other array. If you have a specific problem when trying that, post your code and explain the exact issue. Thanks. – ADyson Aug 22 '23 at 13:32

0 Answers0